Skip to content

Commit b820d82

Browse files
committed
Ensure the permissions of a new redis-sentinel.conf
Without these changes a from-scratch redis-sentinel.conf can be created that is not writable by the redis user, as such the sentinel server will exit immediately after starting. This change ensures the permissions of the *.puppet file and then preserves those permissions upon copy. Unfortunately the copied-to file is hard to test in the spec files, so verification in test is no longer available. It works properly in manual testing.
1 parent f814240 commit b820d82

File tree

2 files changed

+5
-10
lines changed

2 files changed

+5
-10
lines changed

manifests/sentinel.pp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -136,16 +136,14 @@
136136
file {
137137
$config_file_orig:
138138
ensure => present,
139-
content => template($conf_template);
140-
141-
$config_file:
142139
owner => $service_user,
143140
group => $service_group,
144-
mode => $config_file_mode;
141+
mode => $config_file_mode,
142+
content => template($conf_template);
145143
}
146144

147145
exec {
148-
"cp ${config_file_orig} ${config_file}":
146+
"cp -p ${config_file_orig} ${config_file}":
149147
path => '/usr/bin:/bin',
150148
subscribe => File[$config_file_orig],
151149
notify => Service[$service_name],

spec/classes/redis_sentinel_spec.rb

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,12 @@
3333

3434
it { should contain_file('/etc/redis/redis-sentinel.conf.puppet').with(
3535
'ensure' => 'present',
36+
'mode' => '0644',
37+
'owner' => 'redis',
3638
'content' => $expected_noparams_content
3739
)
3840
}
3941

40-
it { should contain_file('/etc/redis/redis-sentinel.conf').with(
41-
'mode' => '0644'
42-
)
43-
}
44-
4542
it { should contain_service('redis-sentinel').with(
4643
'ensure' => 'running',
4744
'enable' => 'true',

0 commit comments

Comments
 (0)