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: I73285227e9bbd0c895d9f74bab9e9bb65acaba40
This commit is contained in:
parent
ebc168957c
commit
20b3cafc0a
@ -45,4 +45,7 @@ Puppet::Type.newtype(:sahara_config) do
|
|||||||
defaultto('<SERVICE DEFAULT>')
|
defaultto('<SERVICE DEFAULT>')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
autorequire(:package) do
|
||||||
|
'sahara-common'
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
@ -479,7 +479,6 @@ class sahara(
|
|||||||
tag => ['openstack', 'sahara-package'],
|
tag => ['openstack', 'sahara-package'],
|
||||||
}
|
}
|
||||||
|
|
||||||
Package['sahara-common'] -> Sahara_config<||>
|
|
||||||
Package['sahara-common'] -> Class['sahara::policy']
|
Package['sahara-common'] -> Class['sahara::policy']
|
||||||
|
|
||||||
sahara_config {
|
sahara_config {
|
||||||
|
@ -49,4 +49,14 @@ describe 'Puppet::Type.type(:sahara_config)' do
|
|||||||
@sahara_config[:ensure] = :latest
|
@sahara_config[:ensure] = :latest
|
||||||
}.to raise_error(Puppet::Error, /Invalid value/)
|
}.to raise_error(Puppet::Error, /Invalid value/)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'should autorequire the package that install the file' do
|
||||||
|
catalog = Puppet::Resource::Catalog.new
|
||||||
|
package = Puppet::Type.type(:package).new(:name => 'sahara-common')
|
||||||
|
catalog.add_resource package, @sahara_config
|
||||||
|
dependency = @sahara_config.autorequire
|
||||||
|
expect(dependency.size).to eq(1)
|
||||||
|
expect(dependency[0].target).to eq(@sahara_config)
|
||||||
|
expect(dependency[0].source).to eq(package)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user