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:
Denis Egorenko 2015-09-17 17:32:09 +03:00
parent ebc168957c
commit 20b3cafc0a
3 changed files with 13 additions and 1 deletions

View File

@ -45,4 +45,7 @@ Puppet::Type.newtype(:sahara_config) do
defaultto('<SERVICE DEFAULT>')
end
autorequire(:package) do
'sahara-common'
end
end

View File

@ -479,7 +479,6 @@ class sahara(
tag => ['openstack', 'sahara-package'],
}
Package['sahara-common'] -> Sahara_config<||>
Package['sahara-common'] -> Class['sahara::policy']
sahara_config {

View File

@ -49,4 +49,14 @@ describe 'Puppet::Type.type(:sahara_config)' do
@sahara_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 => '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