diff --git a/REFERENCE.md b/REFERENCE.md index 85da05a1..def63d6a 100644 --- a/REFERENCE.md +++ b/REFERENCE.md @@ -420,7 +420,7 @@ Data type: `String[1]` group owner of dotfile -Default value: `'root'` +Default value: `getvar('python::params::group')` ##### `config` diff --git a/manifests/dotfile.pp b/manifests/dotfile.pp index 4961f12f..66d59b1e 100644 --- a/manifests/dotfile.pp +++ b/manifests/dotfile.pp @@ -26,7 +26,7 @@ Enum['absent', 'present'] $ensure = 'present', Stdlib::Absolutepath $filename = $title, String[1] $owner = 'root', - String[1] $group = 'root', + String[1] $group = getvar('python::params::group'), Stdlib::Filemode $mode = '0644', Hash $config = {}, ) { diff --git a/spec/defines/dotfile_spec.rb b/spec/defines/dotfile_spec.rb index 30ce21b3..a44426f7 100644 --- a/spec/defines/dotfile_spec.rb +++ b/spec/defines/dotfile_spec.rb @@ -9,6 +9,16 @@ facts end + let(:root_group) do + if facts[:os]['family'] == 'FreeBSD' + 'wheel' + else + 'root' + end + end + + let(:pre_condition) { 'include python' } + describe 'dotfile as' do context 'fails with empty string filename' do let(:title) { '' } @@ -32,7 +42,7 @@ context 'succeeds with filename in a non-existing path' do let(:title) { '/home/someuser/.pip/pip.conf' } - it { is_expected.to contain_exec('create /home/someuser/.pip/pip.conf\'s parent dir').with_command('install -o root -g root -d /home/someuser/.pip') } + it { is_expected.to contain_exec('create /home/someuser/.pip/pip.conf\'s parent dir').with_command("install -o root -g #{root_group} -d /home/someuser/.pip") } it { is_expected.to contain_file('/home/someuser/.pip/pip.conf').with_mode('0644') } end @@ -40,7 +50,7 @@ let(:title) { '/home/someuser/.pip/pip.conf' } let(:params) { { owner: 'someuser' } } - it { is_expected.to contain_exec('create /home/someuser/.pip/pip.conf\'s parent dir').with_command('install -o someuser -g root -d /home/someuser/.pip') } + it { is_expected.to contain_exec('create /home/someuser/.pip/pip.conf\'s parent dir').with_command("install -o someuser -g #{root_group} -d /home/someuser/.pip") } it { is_expected.to contain_file('/home/someuser/.pip/pip.conf').with_owner('someuser') } end