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: I182fb7f7db18ce3b281de5d89148c5b9e4e9638d
This commit is contained in:
@@ -41,4 +41,8 @@ Puppet::Type.newtype(:keystone_config) do
|
||||
defaultto false
|
||||
end
|
||||
|
||||
autorequire(:package) do
|
||||
'keystone'
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -40,4 +40,8 @@ Puppet::Type.newtype(:keystone_paste_ini) do
|
||||
defaultto false
|
||||
end
|
||||
|
||||
autorequire(:package) do
|
||||
'keystone'
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -531,7 +531,7 @@ class keystone(
|
||||
}
|
||||
}
|
||||
|
||||
File['/etc/keystone/keystone.conf'] -> Keystone_config<||> ~> Service[$service_name]
|
||||
Keystone_config<||> ~> Service[$service_name]
|
||||
Keystone_config<||> ~> Exec<| title == 'keystone-manage db_sync'|>
|
||||
Keystone_config<||> ~> Exec<| title == 'keystone-manage pki_setup'|>
|
||||
Keystone_config<||> ~> Exec<| title == 'keystone-manage fernet_setup'|>
|
||||
|
||||
39
spec/unit/provider/keystone_config/ini_setting_spec.rb
Normal file
39
spec/unit/provider/keystone_config/ini_setting_spec.rb
Normal file
@@ -0,0 +1,39 @@
|
||||
#
|
||||
# these tests are a little concerning b/c they are hacking around the
|
||||
# modulepath, so these tests will not catch issues that may eventually arise
|
||||
# related to loading these plugins.
|
||||
# I could not, for the life of me, figure out how to programatcally set the modulepath
|
||||
$LOAD_PATH.push(
|
||||
File.join(
|
||||
File.dirname(__FILE__),
|
||||
'..',
|
||||
'..',
|
||||
'..',
|
||||
'fixtures',
|
||||
'modules',
|
||||
'inifile',
|
||||
'lib')
|
||||
)
|
||||
require 'spec_helper'
|
||||
provider_class = Puppet::Type.type(:keystone_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::Keystone_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::Keystone_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/keystone_config_spec.rb
Normal file
19
spec/unit/type/keystone_config_spec.rb
Normal file
@@ -0,0 +1,19 @@
|
||||
require 'puppet'
|
||||
require 'puppet/type/keystone_config'
|
||||
|
||||
describe 'Puppet::Type.type(:keystone_config)' do
|
||||
before :each do
|
||||
@keystone_config = Puppet::Type.type(:keystone_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 => 'keystone')
|
||||
catalog.add_resource package, @keystone_config
|
||||
dependency = @keystone_config.autorequire
|
||||
expect(dependency.size).to eq(1)
|
||||
expect(dependency[0].target).to eq(@keystone_config)
|
||||
expect(dependency[0].source).to eq(package)
|
||||
end
|
||||
|
||||
end
|
||||
@@ -20,4 +20,15 @@ describe 'Puppet::Type.type(:keystone_paste_ini)' do
|
||||
@keystone_paste_ini[:value] = 'bar'
|
||||
expect(@keystone_paste_ini[:value]).to eq('bar')
|
||||
end
|
||||
|
||||
it 'should autorequire the package that install the file' do
|
||||
catalog = Puppet::Resource::Catalog.new
|
||||
package = Puppet::Type.type(:package).new(:name => 'keystone')
|
||||
catalog.add_resource package, @keystone_paste_ini
|
||||
dependency = @keystone_paste_ini.autorequire
|
||||
expect(dependency.size).to eq(1)
|
||||
expect(dependency[0].target).to eq(@keystone_paste_ini)
|
||||
expect(dependency[0].source).to eq(package)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user