diff --git a/REFERENCE.md b/REFERENCE.md index 36f4f389..35bf69bd 100644 --- a/REFERENCE.md +++ b/REFERENCE.md @@ -125,6 +125,8 @@ The following parameters are available in the `consul` class: * [`enable_beta_ui`](#-consul--enable_beta_ui) * [`allow_binding_to_root_ports`](#-consul--allow_binding_to_root_ports) * [`log_file`](#-consul--log_file) +* [`comment`](#-consul--comment) +* [`uid`](#-consul--uid) ##### `acls` @@ -592,6 +594,22 @@ where should the log file be located Default value: `'/var/log/consul'` +##### `comment` + +Data type: `Optional[String[1]]` + +the comment for the consul user, will be added to /etc/passwd + +Default value: `undef` + +##### `uid` + +Data type: `Optional[Integer[1]]` + +the ID for the consul user + +Default value: `undef` + ## Defined types ### `consul::check` diff --git a/manifests/init.pp b/manifests/init.pp index 34f11dd0..7982c55e 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -73,6 +73,8 @@ # You can enable it by setting this variable to true. Defaults to false # @param allow_binding_to_root_ports enables CAP_NET_BIND_SERVICE if true. This is currently only implemented on systemd nodes # @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 # # @example simple consul setup # class { 'consul': @@ -142,6 +144,8 @@ Optional[String[1]] $shell = $consul::params::shell, Boolean $enable_beta_ui = false, Boolean $allow_binding_to_root_ports = false, + Optional[String[1]] $comment = undef, + Optional[Integer[1]] $uid = undef, ) inherits consul::params { $real_download_url = pick( $download_url, diff --git a/manifests/install.pp b/manifests/install.pp index a5dea517..e727640f 100644 --- a/manifests/install.pp +++ b/manifests/install.pp @@ -102,11 +102,13 @@ } user { $consul::user_real: - ensure => 'present', - system => true, - groups => $consul::extra_groups, - shell => $consul::shell, - home => $consul_user_home, + ensure => 'present', + system => true, + groups => $consul::extra_groups, + shell => $consul::shell, + home => $consul_user_home, + uid => $consul::uid, + comment => $consul::comment, } if ($consul::manage_group) and ($consul::install_method != 'docker' ) { diff --git a/spec/classes/init_spec.rb b/spec/classes/init_spec.rb index 67a36573..c487bd3d 100644 --- a/spec/classes/init_spec.rb +++ b/spec/classes/init_spec.rb @@ -242,7 +242,7 @@ end context 'By default, a user and group should be installed' do - it { is_expected.to contain_user('consul').with(ensure: :present) } + it { is_expected.to contain_user('consul').with(ensure: :present).without_uid.without_comment } it { is_expected.to contain_group('consul').with(ensure: :present) } end @@ -256,6 +256,17 @@ it { is_expected.to contain_user('consul').with(ensure: :present).without_home } end + context 'with uid and comment' do + let :params do + { + uid: 2, + comment: 'this is a comment', + } + end + + it { is_expected.to contain_user('consul').with(ensure: :present).with_uid(2).with_comment('this is a comment') } + end + context 'When data_dir is provided' do let(:params) do {