Skip to content

Commit

Permalink
Add support for managing group ID
Browse files Browse the repository at this point in the history
  • Loading branch information
bastelfreak committed Oct 30, 2024
1 parent bed8462 commit 65734c7
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 1 deletion.
9 changes: 9 additions & 0 deletions REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ The following parameters are available in the `consul` class:
* [`log_file`](#-consul--log_file)
* [`comment`](#-consul--comment)
* [`uid`](#-consul--uid)
* [`gid`](#-consul--gid)

##### <a name="-consul--acls"></a>`acls`

Expand Down Expand Up @@ -610,6 +611,14 @@ the ID for the consul user

Default value: `undef`

##### <a name="-consul--gid"></a>`gid`

Data type: `Optional[Integer[1]]`

the ID for the consul group

Default value: `undef`

## Defined types

### <a name="consul--check"></a>`consul::check`
Expand Down
2 changes: 2 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
# @param log_file where should the log file be located
# @param comment the comment for the consul user, will be added to /etc/passwd
# @param uid the ID for the consul user
# @param gid the ID for the consul group
#
# @example simple consul setup
# class { 'consul':
Expand Down Expand Up @@ -146,6 +147,7 @@
Boolean $allow_binding_to_root_ports = false,
Optional[String[1]] $comment = undef,
Optional[Integer[1]] $uid = undef,
Optional[Integer[1]] $gid = undef,
) inherits consul::params {
$real_download_url = pick(
$download_url,
Expand Down
1 change: 1 addition & 0 deletions manifests/install.pp
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@
group { $consul::group_real:
ensure => 'present',
system => true,
gid => $consul::gid,
}
}
}
4 changes: 3 additions & 1 deletion spec/classes/init_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -256,15 +256,17 @@
it { is_expected.to contain_user('consul').with(ensure: :present).without_home }
end

context 'with uid and comment' do
context 'with uid and comment and gid' do
let :params do
{
uid: 2,
comment: 'this is a comment',
gid: 3,
}
end

it { is_expected.to contain_user('consul').with(ensure: :present).with_uid(2).with_comment('this is a comment') }
it { is_expected.to contain_group('consul').with(ensure: :present).with_gid(3) }
end

context 'When data_dir is provided' do
Expand Down

0 comments on commit 65734c7

Please sign in to comment.