Skip to content

Commit 9d8efec

Browse files
committed
Install all modules before adding custom configs
The problem is that we have defines (apache::custom_config and apache::mod) on both sides so we cannot easily reference the one side from the other (when we want to avoid the <||> syntax). So, we use an anchor as the reference point and make things happen before or after that.
1 parent b4885f2 commit 9d8efec

File tree

4 files changed

+12
-5
lines changed

4 files changed

+12
-5
lines changed

manifests/custom_config.pp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,13 @@
4949
}
5050

5151
if $ensure == 'present' and $verify_config {
52-
exec { "service notify for ${name}":
52+
exec { "syntax verification for ${name}":
5353
command => $verify_command,
5454
subscribe => File["apache_${name}"],
5555
refreshonly => true,
5656
notify => Class['Apache::Service'],
5757
before => Exec["remove ${name} if invalid"],
58+
require => Anchor['::apache::modules_set_up']
5859
}
5960

6061
exec { "remove ${name} if invalid":

manifests/init.pp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,4 +381,8 @@
381381
manage_docroot => $default_ssl_vhost,
382382
}
383383
}
384+
385+
# This anchor can be used as a reference point for things that need to happen *after*
386+
# all modules have been put in place.
387+
anchor { '::apache::modules_set_up': }
384388
}

manifests/mod.pp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,4 +162,6 @@
162162
}
163163
}
164164
}
165+
166+
Apache::Mod[$name] -> Anchor['::apache::modules_set_up']
165167
}

spec/defines/custom_config_spec.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
'content' => '# Test',
2727
}
2828
end
29-
it { is_expected.to contain_exec("service notify for rspec").with({
29+
it { is_expected.to contain_exec("syntax verification for rspec").with({
3030
'refreshonly' => 'true',
3131
'subscribe' => 'File[apache_rspec]',
3232
'command' => '/usr/sbin/apachectl -t',
@@ -56,7 +56,7 @@
5656
'verify_command' => '/bin/true',
5757
}
5858
end
59-
it { is_expected.to contain_exec("service notify for rspec").with({
59+
it { is_expected.to contain_exec("syntax verification for rspec").with({
6060
'command' => '/bin/true',
6161
})
6262
}
@@ -80,7 +80,7 @@
8080
'verify_config' => false,
8181
}
8282
end
83-
it { is_expected.to_not contain_exec('service notify for rspec') }
83+
it { is_expected.to_not contain_exec('syntax verification for rspec') }
8484
it { is_expected.to_not contain_exec('remove rspec if invalid') }
8585
it { is_expected.to contain_file('apache_rspec').with({
8686
'notify' => 'Class[Apache::Service]'
@@ -93,7 +93,7 @@
9393
'ensure' => 'absent'
9494
}
9595
end
96-
it { is_expected.to_not contain_exec('service notify for rspec') }
96+
it { is_expected.to_not contain_exec('syntax verification for rspec') }
9797
it { is_expected.to_not contain_exec('remove rspec if invalid') }
9898
it { is_expected.to contain_file('apache_rspec').with({
9999
'ensure' => 'absent',

0 commit comments

Comments
 (0)