From 7608c376fd864befb82f70fb9468ba4b18ec4c3a Mon Sep 17 00:00:00 2001 From: Fabien Hochstrasser Date: Fri, 9 Apr 2021 09:44:20 +0000 Subject: [PATCH 1/2] Make it possible to set the login shell of the wildfly user. --- manifests/init.pp | 4 +++- manifests/prepare.pp | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index 66bb6e73..a534575c 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -55,7 +55,8 @@ # @param systemd_template Sets a custom systemd template. # @param uid Sets managed user ID. # @param user User to own `JBOSS_HOME`. If `manage_user` is `true`, this user will be managed. -# @param user_home User home directory. Defaults to '/home/wildfly' +# @param user_home User home directory. Defaults to '/home/wildfly'. +# @param user_shell User login shell. Defaults to '/bin/bash'. # @param version Sets the Wildfly version managed in order to handle small differences among versions. class wildfly( Pattern[/^(\d{1,}\.\d{1,}(\.\d{1,})?$)/] $version = '9.0.2', @@ -72,6 +73,7 @@ Boolean $manage_user = true, String $user = 'wildfly', Stdlib::Unixpath $user_home = '/home/wildfly', + Stdlib::Unixpath $user_shell = '/bin/bash', String $group = 'wildfly', String $mode_template = "wildfly/${mode}.conf", String $mgmt_keystore_pass = 'changeit', diff --git a/manifests/prepare.pp b/manifests/prepare.pp index 489e9d92..d831180b 100644 --- a/manifests/prepare.pp +++ b/manifests/prepare.pp @@ -13,7 +13,7 @@ uid => $wildfly::uid, gid => $wildfly::gid, groups => $wildfly::group, - shell => '/bin/bash', + shell => $wildfly::user_shell, home => $wildfly::user_home, comment => "${wildfly::user} user created by Puppet", managehome => true, From 4eee401f8002c7b924775b962870ad5b404435d8 Mon Sep 17 00:00:00 2001 From: Fabien Hochstrasser Date: Fri, 9 Apr 2021 10:27:41 +0000 Subject: [PATCH 2/2] Add unit-test for custom login shell. --- spec/classes/prepare_spec.rb | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/spec/classes/prepare_spec.rb b/spec/classes/prepare_spec.rb index ae721744..49fc7f4b 100644 --- a/spec/classes/prepare_spec.rb +++ b/spec/classes/prepare_spec.rb @@ -89,4 +89,25 @@ .with_home('/opt/wildfly') end end + + context 'set custom user_shell' do + let(:facts) do + { :operatingsystem => 'CentOS', + :kernel => 'Linux', + :osfamily => 'RedHat', + :operatingsystemmajrelease => '7', + :initsystem => 'systemd' } + end + + let :pre_condition do + "class { 'wildfly': + user_shell => '/bin/false', + }" + end + + it do + is_expected.to contain_user('wildfly') + .with_shell('/bin/false') + end + end end