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: I6476060c97d350640b5a254738a60e319ad522e9
This commit is contained in:
parent
2a45eec02d
commit
0cf89d487e
|
@ -44,4 +44,8 @@ Puppet::Type.newtype(:heat_config) do
|
|||
provider.create
|
||||
end
|
||||
|
||||
autorequire(:package) do
|
||||
'heat-common'
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -65,7 +65,6 @@ class heat::api (
|
|||
Heat_config<||> ~> Service['heat-api']
|
||||
Class['heat::policy'] -> Service['heat-api']
|
||||
|
||||
Package['heat-api'] -> Heat_config<||>
|
||||
Package['heat-api'] -> Class['heat::policy']
|
||||
Package['heat-api'] -> Service['heat-api']
|
||||
|
||||
|
|
|
@ -68,7 +68,6 @@ class heat::api_cfn (
|
|||
Heat_config<||> ~> Service['heat-api-cfn']
|
||||
Class['heat::policy'] -> Service['heat-api-cfn']
|
||||
|
||||
Package['heat-api-cfn'] -> Heat_config<||>
|
||||
Package['heat-api-cfn'] -> Class['heat::policy']
|
||||
Package['heat-api-cfn'] -> Service['heat-api-cfn']
|
||||
|
||||
|
|
|
@ -67,7 +67,6 @@ class heat::api_cloudwatch (
|
|||
Heat_config<||> ~> Service['heat-api-cloudwatch']
|
||||
Class['heat::policy'] -> Service['heat-api-cloudwatch']
|
||||
|
||||
Package['heat-api-cloudwatch'] -> Heat_config<||>
|
||||
Package['heat-api-cloudwatch'] -> Class['heat::policy']
|
||||
Package['heat-api-cloudwatch'] -> Service['heat-api-cloudwatch']
|
||||
|
||||
|
|
|
@ -111,7 +111,6 @@ class heat::engine (
|
|||
|
||||
Heat_config<||> ~> Service['heat-engine']
|
||||
|
||||
Package['heat-engine'] -> Heat_config<||>
|
||||
Package['heat-engine'] -> Service['heat-engine']
|
||||
package { 'heat-engine':
|
||||
ensure => $package_ensure,
|
||||
|
|
|
@ -326,8 +326,6 @@ class heat(
|
|||
tag => ['openstack', 'heat-package'],
|
||||
}
|
||||
|
||||
Package['heat-common'] -> Heat_config<||>
|
||||
|
||||
if $rpc_backend == 'heat.openstack.common.rpc.impl_kombu' {
|
||||
|
||||
if $rabbit_hosts {
|
||||
|
|
|
@ -0,0 +1,42 @@
|
|||
$LOAD_PATH.push(
|
||||
File.join(
|
||||
File.dirname(__FILE__),
|
||||
'..',
|
||||
'..',
|
||||
'..',
|
||||
'fixtures',
|
||||
'modules',
|
||||
'inifile',
|
||||
'lib')
|
||||
)
|
||||
|
||||
require 'spec_helper'
|
||||
|
||||
provider_class = Puppet::Type.type(:heat_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::Heat_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::Heat_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,20 @@
|
|||
require 'puppet'
|
||||
require 'puppet/type/heat_config'
|
||||
|
||||
describe 'Puppet::Type.type(:heat_config)' do
|
||||
before :each do
|
||||
@heat_config = Puppet::Type.type(:heat_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 => 'heat-common')
|
||||
catalog.add_resource package, @heat_config
|
||||
dependency = @heat_config.autorequire
|
||||
expect(dependency.size).to eq(1)
|
||||
expect(dependency[0].target).to eq(@heat_config)
|
||||
expect(dependency[0].source).to eq(package)
|
||||
end
|
||||
|
||||
end
|
Loading…
Reference in New Issue