Skip to content

Commit 0aa6c63

Browse files
committed
set group of fragments to gid
gid has now been part of facter for a long time, it is safe to use it now.
1 parent eb04c55 commit 0aa6c63

File tree

3 files changed

+17
-5
lines changed

3 files changed

+17
-5
lines changed

manifests/fragment.pp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,9 @@
7272
$safe_target_name = regsubst($target, '[/:\n]', '_', 'GM')
7373
$concatdir = $concat::setup::concatdir
7474
$fragdir = "${concatdir}/${safe_target_name}"
75-
$fragowner = $concat::setup::fragment_owner
76-
$fragmode = $concat::setup::fragment_mode
75+
$fragowner = $concat::setup::fragment_owner
76+
$fraggroup = $concat::setup::fragment_group
77+
$fragmode = $concat::setup::fragment_mode
7778

7879
# The file type's semantics are problematic in that ensure => present will
7980
# not over write a pre-existing symlink. We are attempting to provide
@@ -110,11 +111,10 @@
110111
crit('No content, source or symlink specified')
111112
}
112113

113-
# punt on group ownership until some point in the distant future when $::gid
114-
# can be relied on to be present
115114
file { "${fragdir}/fragments/${order}_${safe_name}":
116115
ensure => $safe_ensure,
117116
owner => $fragowner,
117+
group => $fraggroup,
118118
mode => $fragmode,
119119
source => $source,
120120
content => $content,

manifests/setup.pp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,16 @@
2020
fail ('$concat_basedir not defined. Try running again with pluginsync=true on the [master] and/or [main] section of your node\'s \'/etc/puppet/puppet.conf\'.')
2121
}
2222

23-
# owner and mode of fragment files (on windows owner and access rights should
23+
# owner,group and mode of fragment files (on windows owner and access rights should
2424
# be inherited from concatdir and not explicitly set to avoid problems)
2525
$fragment_owner = $::osfamily ? { 'windows' => undef, default => $::id }
2626
$fragment_mode = $::osfamily ? { 'windows' => undef, default => '0640' }
27+
# test on gid fact availability to support older facter versions
28+
if defined('$gid') and $::gid and $::osfamily != 'Windows' {
29+
$fragment_group = $::gid
30+
} else {
31+
$fragment_group = undef
32+
}
2733

2834
$script_name = 'concatfragments.rb'
2935

spec/unit/defines/concat_fragment_spec.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
concatdir = '/var/lib/puppet/concat'
1818
fragdir = "#{concatdir}/#{safe_target_name}"
1919
id = 'root'
20+
gid = 'root'
2021
if p[:ensure] == 'absent'
2122
safe_ensure = p[:ensure]
2223
else
@@ -28,6 +29,7 @@
2829
{
2930
:concat_basedir => concatdir,
3031
:id => id,
32+
:gid => gid,
3133
:osfamily => 'Debian',
3234
:path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
3335
:is_pe => false,
@@ -44,6 +46,7 @@
4446
should contain_file("#{fragdir}/fragments/#{p[:order]}_#{safe_name}").with({
4547
:ensure => safe_ensure,
4648
:owner => id,
49+
:group => gid,
4750
:mode => '0640',
4851
:source => p[:source],
4952
:content => p[:content],
@@ -204,6 +207,7 @@
204207
:osfamily => 'Debian',
205208
:id => 'root',
206209
:is_pe => false,
210+
:gid => 'root',
207211
}
208212
end
209213
let(:params) do
@@ -227,6 +231,7 @@
227231
:osfamily => 'Debian',
228232
:id => 'root',
229233
:is_pe => false,
234+
:gid => 'root',
230235
}
231236
end
232237
let(:params) do
@@ -250,6 +255,7 @@
250255
:osfamily => 'Debian',
251256
:id => 'root',
252257
:is_pe => false,
258+
:gid => 'root',
253259
}
254260
end
255261
let(:params) do

0 commit comments

Comments
 (0)