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: Idb19da25958e79787b0c66e4ae275216849a9a2e
This commit is contained in:
parent
4e8e53bff3
commit
d769137e38
@ -40,4 +40,8 @@ Puppet::Type.newtype(:glance_api_config) do
|
|||||||
defaultto false
|
defaultto false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
autorequire(:package) do
|
||||||
|
'glance-api'
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -40,4 +40,8 @@ Puppet::Type.newtype(:glance_api_paste_ini) do
|
|||||||
defaultto false
|
defaultto false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
autorequire(:package) do
|
||||||
|
'glance-api'
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -40,4 +40,8 @@ Puppet::Type.newtype(:glance_cache_config) do
|
|||||||
defaultto false
|
defaultto false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
autorequire(:package) do
|
||||||
|
'glance-api'
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -40,4 +40,8 @@ Puppet::Type.newtype(:glance_registry_config) do
|
|||||||
defaultto false
|
defaultto false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
autorequire(:package) do
|
||||||
|
'glance-registry'
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -40,4 +40,8 @@ Puppet::Type.newtype(:glance_registry_paste_ini) do
|
|||||||
defaultto false
|
defaultto false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
autorequire(:package) do
|
||||||
|
'glance-registry'
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -240,7 +240,7 @@ class glance::api(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ( $glance::params::api_package_name != $glance::params::registry_package_name ) {
|
if ( $glance::params::api_package_name != $glance::params::registry_package_name ) {
|
||||||
ensure_packages([$glance::params::api_package_name],
|
ensure_packages('glance-api',
|
||||||
{
|
{
|
||||||
ensure => $package_ensure,
|
ensure => $package_ensure,
|
||||||
tag => ['openstack', 'glance-package'],
|
tag => ['openstack', 'glance-package'],
|
||||||
@ -250,8 +250,6 @@ class glance::api(
|
|||||||
|
|
||||||
Package[$glance::params::api_package_name] -> File['/etc/glance/']
|
Package[$glance::params::api_package_name] -> File['/etc/glance/']
|
||||||
Package[$glance::params::api_package_name] -> Class['glance::policy']
|
Package[$glance::params::api_package_name] -> Class['glance::policy']
|
||||||
Package[$glance::params::api_package_name] -> Glance_api_config<||>
|
|
||||||
Package[$glance::params::api_package_name] -> Glance_cache_config<||>
|
|
||||||
|
|
||||||
# adding all of this stuff b/c it devstack says glance-api uses the
|
# adding all of this stuff b/c it devstack says glance-api uses the
|
||||||
# db now
|
# db now
|
||||||
|
@ -169,7 +169,7 @@ class glance::registry(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ( $glance::params::api_package_name != $glance::params::registry_package_name ) {
|
if ( $glance::params::api_package_name != $glance::params::registry_package_name ) {
|
||||||
ensure_packages( [$glance::params::registry_package_name],
|
ensure_packages( 'glance-registry',
|
||||||
{
|
{
|
||||||
ensure => $package_ensure,
|
ensure => $package_ensure,
|
||||||
tag => ['openstack', 'glance-package'],
|
tag => ['openstack', 'glance-package'],
|
||||||
@ -178,7 +178,6 @@ class glance::registry(
|
|||||||
}
|
}
|
||||||
|
|
||||||
Package[$glance::params::registry_package_name] -> File['/etc/glance/']
|
Package[$glance::params::registry_package_name] -> File['/etc/glance/']
|
||||||
Package[$glance::params::registry_package_name] -> Glance_registry_config<||>
|
|
||||||
|
|
||||||
Glance_registry_config<||> ~> Exec<| title == 'glance-manage db_sync' |>
|
Glance_registry_config<||> ~> Exec<| title == 'glance-manage db_sync' |>
|
||||||
Glance_registry_config<||> ~> Service['glance-registry']
|
Glance_registry_config<||> ~> Service['glance-registry']
|
||||||
|
42
spec/unit/provider/glance_api_config/ini_setting_spec.rb
Normal file
42
spec/unit/provider/glance_api_config/ini_setting_spec.rb
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
$LOAD_PATH.push(
|
||||||
|
File.join(
|
||||||
|
File.dirname(__FILE__),
|
||||||
|
'..',
|
||||||
|
'..',
|
||||||
|
'..',
|
||||||
|
'fixtures',
|
||||||
|
'modules',
|
||||||
|
'inifile',
|
||||||
|
'lib')
|
||||||
|
)
|
||||||
|
|
||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
provider_class = Puppet::Type.type(:glance_api_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::Glance_api_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::Glance_api_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
|
42
spec/unit/provider/glance_cache_config/ini_setting_spec.rb
Normal file
42
spec/unit/provider/glance_cache_config/ini_setting_spec.rb
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
$LOAD_PATH.push(
|
||||||
|
File.join(
|
||||||
|
File.dirname(__FILE__),
|
||||||
|
'..',
|
||||||
|
'..',
|
||||||
|
'..',
|
||||||
|
'fixtures',
|
||||||
|
'modules',
|
||||||
|
'inifile',
|
||||||
|
'lib')
|
||||||
|
)
|
||||||
|
|
||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
provider_class = Puppet::Type.type(:glance_cache_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::Glance_cache_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::Glance_cache_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,42 @@
|
|||||||
|
$LOAD_PATH.push(
|
||||||
|
File.join(
|
||||||
|
File.dirname(__FILE__),
|
||||||
|
'..',
|
||||||
|
'..',
|
||||||
|
'..',
|
||||||
|
'fixtures',
|
||||||
|
'modules',
|
||||||
|
'inifile',
|
||||||
|
'lib')
|
||||||
|
)
|
||||||
|
|
||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
provider_class = Puppet::Type.type(:glance_registry_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::Glance_registry_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::Glance_registry_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
|
19
spec/unit/type/glance_api_config_spec.rb
Normal file
19
spec/unit/type/glance_api_config_spec.rb
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
require 'puppet'
|
||||||
|
require 'puppet/type/glance_api_config'
|
||||||
|
|
||||||
|
describe 'Puppet::Type.type(:glance_api_config)' do
|
||||||
|
before :each do
|
||||||
|
@glance_api_config = Puppet::Type.type(:glance_api_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 => 'glance-api')
|
||||||
|
catalog.add_resource package, @glance_api_config
|
||||||
|
dependency = @glance_api_config.autorequire
|
||||||
|
expect(dependency.size).to eq(1)
|
||||||
|
expect(dependency[0].target).to eq(@glance_api_config)
|
||||||
|
expect(dependency[0].source).to eq(package)
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
19
spec/unit/type/glance_cache_config_spec.rb
Normal file
19
spec/unit/type/glance_cache_config_spec.rb
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
require 'puppet'
|
||||||
|
require 'puppet/type/glance_cache_config'
|
||||||
|
|
||||||
|
describe 'Puppet::Type.type(:glance_cache_config)' do
|
||||||
|
before :each do
|
||||||
|
@glance_cache_config = Puppet::Type.type(:glance_cache_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 => 'glance-api')
|
||||||
|
catalog.add_resource package, @glance_cache_config
|
||||||
|
dependency = @glance_cache_config.autorequire
|
||||||
|
expect(dependency.size).to eq(1)
|
||||||
|
expect(dependency[0].target).to eq(@glance_cache_config)
|
||||||
|
expect(dependency[0].source).to eq(package)
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
19
spec/unit/type/glance_registry_config_spec.rb
Normal file
19
spec/unit/type/glance_registry_config_spec.rb
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
require 'puppet'
|
||||||
|
require 'puppet/type/glance_registry_config'
|
||||||
|
|
||||||
|
describe 'Puppet::Type.type(:glance_registry_config)' do
|
||||||
|
before :each do
|
||||||
|
@glance_registry_config = Puppet::Type.type(:glance_registry_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 => 'glance-registry')
|
||||||
|
catalog.add_resource package, @glance_registry_config
|
||||||
|
dependency = @glance_registry_config.autorequire
|
||||||
|
expect(dependency.size).to eq(1)
|
||||||
|
expect(dependency[0].target).to eq(@glance_registry_config)
|
||||||
|
expect(dependency[0].source).to eq(package)
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
Loading…
Reference in New Issue
Block a user