Rely on autorequire for config resource ordering
Currently we specify the ordering of config resources wherever it is necessary based on the presence of the file it will write to, or the presence of the package in charge of providing the file it will write to. Those kind of ordering can be specified directly at the resource level using the autorequire mechanism. With this patch, any config resource will make sure the package in charge of providing the file will be installed first. Change-Id: If90d097129bad922511465345d577df37d84e78b
This commit is contained in:
parent
dd80631f4b
commit
e5828de78b
@ -39,4 +39,9 @@ Puppet::Type.newtype(:tuskar_config) do
|
||||
|
||||
defaultto false
|
||||
end
|
||||
|
||||
autorequire(:package) do
|
||||
'tuskar-api'
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -111,7 +111,6 @@ class tuskar::api(
|
||||
|
||||
Tuskar_config<||> ~> Exec['post-tuskar_config']
|
||||
Tuskar_config<||> ~> Service['tuskar-api']
|
||||
Package['tuskar-api'] -> Tuskar_config<||>
|
||||
|
||||
if $::tuskar::database_connection {
|
||||
if($::tuskar::database_connection =~ /mysql:\/\/\S+:\S+@\S+\/\S+/) {
|
||||
|
@ -49,4 +49,15 @@ describe 'Puppet::Type.type(:tuskar_config)' do
|
||||
@tuskar_config[:ensure] = :latest
|
||||
}.to raise_error(Puppet::Error, /Invalid value/)
|
||||
end
|
||||
|
||||
it 'should autorequire the package that install the file' do
|
||||
catalog = Puppet::Resource::Catalog.new
|
||||
package = Puppet::Type.type(:package).new(:name => 'tuskar-api')
|
||||
catalog.add_resource package, @tuskar_config
|
||||
dependency = @tuskar_config.autorequire
|
||||
expect(dependency.size).to eq(1)
|
||||
expect(dependency[0].target).to eq(@tuskar_config)
|
||||
expect(dependency[0].source).to eq(package)
|
||||
end
|
||||
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user