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: I121f3cf146d9909cd549bd2e252f8cc645e5a030
This commit is contained in:
parent
005d532a4f
commit
69fa700138
|
@ -39,4 +39,9 @@ Puppet::Type.newtype(:ironic_config) do
|
|||
|
||||
defaultto false
|
||||
end
|
||||
|
||||
autorequire(:package) do
|
||||
'ironic-common'
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -119,7 +119,6 @@ class ironic::api (
|
|||
if $::ironic::params::api_package {
|
||||
Package['ironic-api'] -> Class['ironic::policy']
|
||||
Package['ironic-api'] -> Service['ironic-api']
|
||||
Package['ironic-api'] -> Ironic_config<||>
|
||||
package { 'ironic-api':
|
||||
ensure => $package_ensure,
|
||||
name => $::ironic::params::api_package,
|
||||
|
|
|
@ -58,7 +58,6 @@ class ironic::conductor (
|
|||
# Install package
|
||||
if $::ironic::params::conductor_package {
|
||||
Package['ironic-conductor'] -> Service['ironic-conductor']
|
||||
Package['ironic-conductor'] -> Ironic_config<||>
|
||||
package { 'ironic-conductor':
|
||||
ensure => $package_ensure,
|
||||
name => $::ironic::params::conductor_package,
|
||||
|
|
|
@ -239,8 +239,6 @@ class ironic (
|
|||
$rabbit_user_real = $rabbit_userid
|
||||
}
|
||||
|
||||
Package['ironic-common'] -> Ironic_config<||>
|
||||
|
||||
file { '/etc/ironic':
|
||||
ensure => directory,
|
||||
require => Package['ironic-common'],
|
||||
|
|
|
@ -51,7 +51,6 @@ describe 'ironic::api' do
|
|||
:ensure => p[:package_ensure],
|
||||
:tag => ['openstack', 'ironic-package'],
|
||||
)
|
||||
is_expected.to contain_package('ironic-api').with_before(/Ironic_config\[.+\]/)
|
||||
is_expected.to contain_package('ironic-api').with_before(/Service\[ironic-api\]/)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -47,7 +47,6 @@ describe 'ironic::conductor' do
|
|||
:ensure => p[:package_ensure],
|
||||
:tag => ['openstack', 'ironic-package'],
|
||||
)
|
||||
is_expected.to contain_package('ironic-conductor').with_before(/Ironic_config\[.+\]/)
|
||||
is_expected.to contain_package('ironic-conductor').with_before(/Service\[ironic-conductor\]/)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -0,0 +1,42 @@
|
|||
$LOAD_PATH.push(
|
||||
File.join(
|
||||
File.dirname(__FILE__),
|
||||
'..',
|
||||
'..',
|
||||
'..',
|
||||
'fixtures',
|
||||
'modules',
|
||||
'inifile',
|
||||
'lib')
|
||||
)
|
||||
|
||||
require 'spec_helper'
|
||||
|
||||
provider_class = Puppet::Type.type(:ironic_config).provider(:ini_setting)
|
||||
|
||||
describe provider_class do
|
||||
|
||||
it 'should default to the default setting when no other one is specified' do
|
||||
resource = Puppet::Type::Ironic_config.new(
|
||||
{
|
||||
:name => 'DEFAULT/foo',
|
||||
:value => 'bar'
|
||||
}
|
||||
)
|
||||
provider = provider_class.new(resource)
|
||||
expect(provider.section).to eq('DEFAULT')
|
||||
expect(provider.setting).to eq('foo')
|
||||
end
|
||||
|
||||
it 'should allow setting to be set explicitly' do
|
||||
resource = Puppet::Type::Ironic_config.new(
|
||||
{
|
||||
:name => 'dude/foo',
|
||||
:value => 'bar'
|
||||
}
|
||||
)
|
||||
provider = provider_class.new(resource)
|
||||
expect(provider.section).to eq('dude')
|
||||
expect(provider.setting).to eq('foo')
|
||||
end
|
||||
end
|
|
@ -0,0 +1,19 @@
|
|||
require 'puppet'
|
||||
require 'puppet/type/ironic_config'
|
||||
|
||||
describe 'Puppet::Type.type(:ironic_config)' do
|
||||
before :each do
|
||||
@ironic_config = Puppet::Type.type(:ironic_config).new(:name => 'DEFAULT/foo', :value => 'bar')
|
||||
end
|
||||
|
||||
it 'should autorequire the package that install the file' do
|
||||
catalog = Puppet::Resource::Catalog.new
|
||||
package = Puppet::Type.type(:package).new(:name => 'ironic-common')
|
||||
catalog.add_resource package, @ironic_config
|
||||
dependency = @ironic_config.autorequire
|
||||
expect(dependency.size).to eq(1)
|
||||
expect(dependency[0].target).to eq(@ironic_config)
|
||||
expect(dependency[0].source).to eq(package)
|
||||
end
|
||||
|
||||
end
|
Loading…
Reference in New Issue