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: Icb3464cc0a747d40326d610d38806d059c9a0fc3
This commit is contained in:
parent
43bb515ea3
commit
a72e27f83c
@ -37,4 +37,9 @@ Puppet::Type.newtype(:swift_account_config) do
|
||||
newvalues(:true, :false)
|
||||
defaultto false
|
||||
end
|
||||
|
||||
autorequire(:package) do
|
||||
'swift-account'
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -37,4 +37,9 @@ Puppet::Type.newtype(:swift_bench_config) do
|
||||
newvalues(:true, :false)
|
||||
defaultto false
|
||||
end
|
||||
|
||||
autorequire(:package) do
|
||||
'swift'
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -39,8 +39,8 @@ Puppet::Type.newtype(:swift_config) do
|
||||
end
|
||||
|
||||
# Require the swift.conf to be present
|
||||
autorequire(:file) do
|
||||
['/etc/swift/swift.conf']
|
||||
autorequire(:package) do
|
||||
'swift'
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -37,4 +37,9 @@ Puppet::Type.newtype(:swift_container_config) do
|
||||
newvalues(:true, :false)
|
||||
defaultto false
|
||||
end
|
||||
|
||||
autorequire(:package) do
|
||||
'swift-container'
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -37,4 +37,9 @@ Puppet::Type.newtype(:swift_dispersion_config) do
|
||||
newvalues(:true, :false)
|
||||
defaultto false
|
||||
end
|
||||
|
||||
autorequire(:package) do
|
||||
'swift'
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -37,4 +37,9 @@ Puppet::Type.newtype(:swift_object_config) do
|
||||
newvalues(:true, :false)
|
||||
defaultto false
|
||||
end
|
||||
|
||||
autorequire(:package) do
|
||||
'swift-object'
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -37,4 +37,9 @@ Puppet::Type.newtype(:swift_proxy_config) do
|
||||
newvalues(:true, :false)
|
||||
defaultto false
|
||||
end
|
||||
|
||||
autorequire(:package) do
|
||||
'swift-proxy'
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -84,8 +84,6 @@ class swift::bench (
|
||||
$delete = 'yes',
|
||||
){
|
||||
|
||||
Package['swift'] -> Swift_bench_config<||>
|
||||
|
||||
swift_bench_config {
|
||||
'bench/auth': value => $auth_url;
|
||||
'bench/user': value => $swift_user;
|
||||
|
@ -82,7 +82,6 @@ class swift::dispersion (
|
||||
|
||||
include ::swift::params
|
||||
|
||||
Package['swift'] -> Swift_dispersion_config<||>
|
||||
Swift_dispersion_config<||> ~> Exec['swift-dispersion-populate']
|
||||
|
||||
file { '/etc/swift/dispersion.conf':
|
||||
|
@ -37,8 +37,6 @@ class swift(
|
||||
|
||||
include ::swift::params
|
||||
|
||||
File['/etc/swift/swift.conf'] -> Swift_config <||>
|
||||
|
||||
if !defined(Package['swift']) {
|
||||
package { 'swift':
|
||||
ensure => $package_ensure,
|
||||
|
@ -37,10 +37,6 @@ describe 'swift::bench' do
|
||||
shared_examples 'swift::bench' do
|
||||
let (:p) { default_params.merge!(params) }
|
||||
|
||||
it 'depends on swift package' do
|
||||
is_expected.to contain_package('swift').with_before(/Swift_bench_config\[.+\]/)
|
||||
end
|
||||
|
||||
it 'configures swift-bench.conf' do
|
||||
is_expected.to contain_swift_bench_config(
|
||||
'bench/auth').with_value(p[:auth_url])
|
||||
|
@ -39,10 +39,6 @@ describe 'swift::dispersion' do
|
||||
shared_examples 'swift::dispersion' do
|
||||
let (:p) { default_params.merge!(params) }
|
||||
|
||||
it 'depends on swift package' do
|
||||
is_expected.to contain_package('swift').with_before(/Swift_dispersion_config\[.+\]/)
|
||||
end
|
||||
|
||||
it 'configures dispersion.conf' do
|
||||
is_expected.to contain_swift_dispersion_config(
|
||||
'dispersion/auth_url').with_value(p[:auth_url])
|
||||
|
42
spec/unit/provider/swift_account_config/ini_setting_spec.rb
Normal file
42
spec/unit/provider/swift_account_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(:swift_account_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::Swift_account_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::Swift_account_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/swift_bench_config/ini_setting_spec.rb
Normal file
42
spec/unit/provider/swift_bench_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(:swift_bench_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::Swift_bench_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::Swift_bench_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/swift_config/ini_setting_spec.rb
Normal file
42
spec/unit/provider/swift_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(:swift_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::Swift_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::Swift_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(:swift_container_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::Swift_container_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::Swift_container_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(:swift_dispersion_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::Swift_dispersion_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::Swift_dispersion_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/swift_object_config/ini_setting_spec.rb
Normal file
42
spec/unit/provider/swift_object_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(:swift_object_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::Swift_object_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::Swift_object_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/swift_proxy_config/ini_setting_spec.rb
Normal file
42
spec/unit/provider/swift_proxy_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(:swift_proxy_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::Swift_proxy_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::Swift_proxy_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/swift_account_config_spec.rb
Normal file
19
spec/unit/type/swift_account_config_spec.rb
Normal file
@ -0,0 +1,19 @@
|
||||
require 'puppet'
|
||||
require 'puppet/type/swift_account_config'
|
||||
|
||||
describe 'Puppet::Type.type(:swift_account_config)' do
|
||||
before :each do
|
||||
@swift_account_config = Puppet::Type.type(:swift_account_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 => 'swift-account')
|
||||
catalog.add_resource package, @swift_account_config
|
||||
dependency = @swift_account_config.autorequire
|
||||
expect(dependency.size).to eq(1)
|
||||
expect(dependency[0].target).to eq(@swift_account_config)
|
||||
expect(dependency[0].source).to eq(package)
|
||||
end
|
||||
|
||||
end
|
19
spec/unit/type/swift_bench_config_spec.rb
Normal file
19
spec/unit/type/swift_bench_config_spec.rb
Normal file
@ -0,0 +1,19 @@
|
||||
require 'puppet'
|
||||
require 'puppet/type/swift_bench_config'
|
||||
|
||||
describe 'Puppet::Type.type(:swift_bench_config)' do
|
||||
before :each do
|
||||
@swift_bench_config = Puppet::Type.type(:swift_bench_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 => 'swift')
|
||||
catalog.add_resource package, @swift_bench_config
|
||||
dependency = @swift_bench_config.autorequire
|
||||
expect(dependency.size).to eq(1)
|
||||
expect(dependency[0].target).to eq(@swift_bench_config)
|
||||
expect(dependency[0].source).to eq(package)
|
||||
end
|
||||
|
||||
end
|
19
spec/unit/type/swift_config_spec.rb
Normal file
19
spec/unit/type/swift_config_spec.rb
Normal file
@ -0,0 +1,19 @@
|
||||
require 'puppet'
|
||||
require 'puppet/type/swift_config'
|
||||
|
||||
describe 'Puppet::Type.type(:swift_config)' do
|
||||
before :each do
|
||||
@swift_config = Puppet::Type.type(:swift_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 => 'swift')
|
||||
catalog.add_resource package, @swift_config
|
||||
dependency = @swift_config.autorequire
|
||||
expect(dependency.size).to eq(1)
|
||||
expect(dependency[0].target).to eq(@swift_config)
|
||||
expect(dependency[0].source).to eq(package)
|
||||
end
|
||||
|
||||
end
|
19
spec/unit/type/swift_container_config_spec.rb
Normal file
19
spec/unit/type/swift_container_config_spec.rb
Normal file
@ -0,0 +1,19 @@
|
||||
require 'puppet'
|
||||
require 'puppet/type/swift_container_config'
|
||||
|
||||
describe 'Puppet::Type.type(:swift_container_config)' do
|
||||
before :each do
|
||||
@swift_container_config = Puppet::Type.type(:swift_container_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 => 'swift-container')
|
||||
catalog.add_resource package, @swift_container_config
|
||||
dependency = @swift_container_config.autorequire
|
||||
expect(dependency.size).to eq(1)
|
||||
expect(dependency[0].target).to eq(@swift_container_config)
|
||||
expect(dependency[0].source).to eq(package)
|
||||
end
|
||||
|
||||
end
|
19
spec/unit/type/swift_dispersion_config_spec.rb
Normal file
19
spec/unit/type/swift_dispersion_config_spec.rb
Normal file
@ -0,0 +1,19 @@
|
||||
require 'puppet'
|
||||
require 'puppet/type/swift_dispersion_config'
|
||||
|
||||
describe 'Puppet::Type.type(:swift_dispersion_config)' do
|
||||
before :each do
|
||||
@swift_dispersion_config = Puppet::Type.type(:swift_dispersion_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 => 'swift')
|
||||
catalog.add_resource package, @swift_dispersion_config
|
||||
dependency = @swift_dispersion_config.autorequire
|
||||
expect(dependency.size).to eq(1)
|
||||
expect(dependency[0].target).to eq(@swift_dispersion_config)
|
||||
expect(dependency[0].source).to eq(package)
|
||||
end
|
||||
|
||||
end
|
19
spec/unit/type/swift_object_config_spec.rb
Normal file
19
spec/unit/type/swift_object_config_spec.rb
Normal file
@ -0,0 +1,19 @@
|
||||
require 'puppet'
|
||||
require 'puppet/type/swift_object_config'
|
||||
|
||||
describe 'Puppet::Type.type(:swift_object_config)' do
|
||||
before :each do
|
||||
@swift_object_config = Puppet::Type.type(:swift_object_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 => 'swift-object')
|
||||
catalog.add_resource package, @swift_object_config
|
||||
dependency = @swift_object_config.autorequire
|
||||
expect(dependency.size).to eq(1)
|
||||
expect(dependency[0].target).to eq(@swift_object_config)
|
||||
expect(dependency[0].source).to eq(package)
|
||||
end
|
||||
|
||||
end
|
19
spec/unit/type/swift_proxy_config_spec.rb
Normal file
19
spec/unit/type/swift_proxy_config_spec.rb
Normal file
@ -0,0 +1,19 @@
|
||||
require 'puppet'
|
||||
require 'puppet/type/swift_proxy_config'
|
||||
|
||||
describe 'Puppet::Type.type(:swift_proxy_config)' do
|
||||
before :each do
|
||||
@swift_proxy_config = Puppet::Type.type(:swift_proxy_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 => 'swift-proxy')
|
||||
catalog.add_resource package, @swift_proxy_config
|
||||
dependency = @swift_proxy_config.autorequire
|
||||
expect(dependency.size).to eq(1)
|
||||
expect(dependency[0].target).to eq(@swift_proxy_config)
|
||||
expect(dependency[0].source).to eq(package)
|
||||
end
|
||||
|
||||
end
|
Loading…
Reference in New Issue
Block a user