Skip to content

Commit 6a59421

Browse files
committed
Merge pull request puppetlabs#1230 from MasonM/fix-ordering-issues-with-ports-file
Fix ordering issue with conf_file and ports_file
2 parents f515778 + e226ba8 commit 6a59421

File tree

3 files changed

+23
-2
lines changed

3 files changed

+23
-2
lines changed

manifests/init.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@
327327
ensure => file,
328328
content => template($conf_template),
329329
notify => Class['Apache::Service'],
330-
require => Package['httpd'],
330+
require => [Package['httpd'], File[$ports_file]],
331331
}
332332

333333
# preserve back-wards compatibility to the times when default_mods was

spec/acceptance/custom_config_spec.rb

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,25 @@ class { 'apache': }
5252
it { is_expected.to be_file }
5353
end
5454
end
55+
56+
describe 'custom_config only applied after configs are written' do
57+
it 'applies in the right order' do
58+
pp = <<-EOS
59+
class { 'apache': }
60+
61+
apache::custom_config { 'ordering_test':
62+
content => '# just a comment',
63+
}
64+
65+
# Try to wedge the apache::custom_config call between when httpd.conf is written and
66+
# ports.conf is written. This should trigger a dependency cycle
67+
File["#{$conf_file}"] -> Apache::Custom_config['ordering_test'] -> File["#{$ports_file}"]
68+
EOS
69+
expect(apply_manifest(pp, :expect_failures => true).stderr).to match(/Failed to apply catalog: Found 1 dependency cycle/i)
70+
end
71+
72+
describe file("#{$confd_dir}/25-ordering_test.conf") do
73+
it { is_expected.not_to be_file }
74+
end
75+
end
5576
end

spec/classes/apache_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,7 @@
480480
it { is_expected.to contain_file("/opt/rh/root/etc/httpd/conf/httpd.conf").with(
481481
'ensure' => 'file',
482482
'notify' => 'Class[Apache::Service]',
483-
'require' => 'Package[httpd]'
483+
'require' => ['Package[httpd]', 'File[/etc/httpd/conf/ports.conf]'],
484484
) }
485485
end
486486

0 commit comments

Comments
 (0)