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: I8f959e4ebbce2545843a901345a2ac3daf4259a1
This commit is contained in:
Yanis Guenane 2015-08-12 10:12:50 +02:00
parent 35efc0e795
commit 712bfd942c
3 changed files with 20 additions and 0 deletions

View File

@ -40,4 +40,8 @@ Puppet::Type.newtype(:designate_api_paste_ini) do
defaultto false
end
autorequire(:package) do
'designate-common'
end
end

View File

@ -40,4 +40,9 @@ Puppet::Type.newtype(:designate_config) do
defaultto false
end
autorequire(:package) do
'designate-common'
end
end

View File

@ -49,4 +49,15 @@ describe 'Puppet::Type.type(:designate_config)' do
@designate_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 => 'designate-common')
catalog.add_resource package, @designate_config
dependency = @designate_config.autorequire
expect(dependency.size).to eq(1)
expect(dependency[0].target).to eq(@designate_config)
expect(dependency[0].source).to eq(package)
end
end