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: Ide679a11b1ebb7609f97f75fd93dc53be5eb92f3
This commit is contained in:
Yanis Guenane 2015-08-12 10:53:19 +02:00
parent 4c1a34d720
commit e2a7d0da4d
5 changed files with 21 additions and 8 deletions

View File

@ -39,4 +39,9 @@ Puppet::Type.newtype(:nova_config) do
defaultto false
end
autorequire(:package) do
'nova-common'
end
end

View File

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

View File

@ -188,8 +188,6 @@ class nova::api(
require ::keystone::python
include ::cinder::client
Package<| title == 'nova-api' |> -> Nova_paste_api_ini<| |>
Package<| title == 'nova-common' |> -> Class['nova::api']
Package<| title == 'nova-common' |> -> Class['nova::policy']

View File

@ -411,12 +411,6 @@ class nova(
}
}
# all nova_config resources should be applied
# after the nova common package
# before the file resource for nova.conf is managed
# and before the post config resource
Package['nova-common'] -> Nova_config<| |> -> File['/etc/nova/nova.conf']
Nova_config<| |> ~> Exec['post-nova_config']
# TODO - see if these packages can be removed

View File

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