Skip to content

Commit

Permalink
Install all modules before adding custom configs
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mpdude committed Oct 9, 2015
1 parent b4885f2 commit 9d8efec
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
3 changes: 2 additions & 1 deletion manifests/custom_config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,13 @@
}

if $ensure == 'present' and $verify_config {
exec { "service notify for ${name}":
exec { "syntax verification for ${name}":
command => $verify_command,
subscribe => File["apache_${name}"],
refreshonly => true,
notify => Class['Apache::Service'],
before => Exec["remove ${name} if invalid"],
require => Anchor['::apache::modules_set_up']
}

exec { "remove ${name} if invalid":
Expand Down
4 changes: 4 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -381,4 +381,8 @@
manage_docroot => $default_ssl_vhost,
}
}

# This anchor can be used as a reference point for things that need to happen *after*
# all modules have been put in place.
anchor { '::apache::modules_set_up': }
}
2 changes: 2 additions & 0 deletions manifests/mod.pp
Original file line number Diff line number Diff line change
Expand Up @@ -162,4 +162,6 @@
}
}
}

Apache::Mod[$name] -> Anchor['::apache::modules_set_up']
}
8 changes: 4 additions & 4 deletions spec/defines/custom_config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
'content' => '# Test',
}
end
it { is_expected.to contain_exec("service notify for rspec").with({
it { is_expected.to contain_exec("syntax verification for rspec").with({
'refreshonly' => 'true',
'subscribe' => 'File[apache_rspec]',
'command' => '/usr/sbin/apachectl -t',
Expand Down Expand Up @@ -56,7 +56,7 @@
'verify_command' => '/bin/true',
}
end
it { is_expected.to contain_exec("service notify for rspec").with({
it { is_expected.to contain_exec("syntax verification for rspec").with({
'command' => '/bin/true',
})
}
Expand All @@ -80,7 +80,7 @@
'verify_config' => false,
}
end
it { is_expected.to_not contain_exec('service notify for rspec') }
it { is_expected.to_not contain_exec('syntax verification for rspec') }
it { is_expected.to_not contain_exec('remove rspec if invalid') }
it { is_expected.to contain_file('apache_rspec').with({
'notify' => 'Class[Apache::Service]'
Expand All @@ -93,7 +93,7 @@
'ensure' => 'absent'
}
end
it { is_expected.to_not contain_exec('service notify for rspec') }
it { is_expected.to_not contain_exec('syntax verification for rspec') }
it { is_expected.to_not contain_exec('remove rspec if invalid') }
it { is_expected.to contain_file('apache_rspec').with({
'ensure' => 'absent',
Expand Down

0 comments on commit 9d8efec

Please sign in to comment.