diff --git a/lib/puppet/type/swift_account_config.rb b/lib/puppet/type/swift_account_config.rb index 6b378a3e..3a6da9b9 100644 --- a/lib/puppet/type/swift_account_config.rb +++ b/lib/puppet/type/swift_account_config.rb @@ -37,4 +37,9 @@ Puppet::Type.newtype(:swift_account_config) do newvalues(:true, :false) defaultto false end + + autorequire(:package) do + 'swift-account' + end + end diff --git a/lib/puppet/type/swift_bench_config.rb b/lib/puppet/type/swift_bench_config.rb index 47f60e60..caa79c6b 100644 --- a/lib/puppet/type/swift_bench_config.rb +++ b/lib/puppet/type/swift_bench_config.rb @@ -37,4 +37,9 @@ Puppet::Type.newtype(:swift_bench_config) do newvalues(:true, :false) defaultto false end + + autorequire(:package) do + 'swift' + end + end diff --git a/lib/puppet/type/swift_config.rb b/lib/puppet/type/swift_config.rb index e16a8460..2ded9cec 100644 --- a/lib/puppet/type/swift_config.rb +++ b/lib/puppet/type/swift_config.rb @@ -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 diff --git a/lib/puppet/type/swift_container_config.rb b/lib/puppet/type/swift_container_config.rb index 421ff72d..ea241eb0 100644 --- a/lib/puppet/type/swift_container_config.rb +++ b/lib/puppet/type/swift_container_config.rb @@ -37,4 +37,9 @@ Puppet::Type.newtype(:swift_container_config) do newvalues(:true, :false) defaultto false end + + autorequire(:package) do + 'swift-container' + end + end diff --git a/lib/puppet/type/swift_dispersion_config.rb b/lib/puppet/type/swift_dispersion_config.rb index 69d21b03..d4c0c8f2 100644 --- a/lib/puppet/type/swift_dispersion_config.rb +++ b/lib/puppet/type/swift_dispersion_config.rb @@ -37,4 +37,9 @@ Puppet::Type.newtype(:swift_dispersion_config) do newvalues(:true, :false) defaultto false end + + autorequire(:package) do + 'swift' + end + end diff --git a/lib/puppet/type/swift_object_config.rb b/lib/puppet/type/swift_object_config.rb index 8a4e5d9f..1bedc667 100644 --- a/lib/puppet/type/swift_object_config.rb +++ b/lib/puppet/type/swift_object_config.rb @@ -37,4 +37,9 @@ Puppet::Type.newtype(:swift_object_config) do newvalues(:true, :false) defaultto false end + + autorequire(:package) do + 'swift-object' + end + end diff --git a/lib/puppet/type/swift_proxy_config.rb b/lib/puppet/type/swift_proxy_config.rb index c7cf34cb..5f8932ea 100644 --- a/lib/puppet/type/swift_proxy_config.rb +++ b/lib/puppet/type/swift_proxy_config.rb @@ -37,4 +37,9 @@ Puppet::Type.newtype(:swift_proxy_config) do newvalues(:true, :false) defaultto false end + + autorequire(:package) do + 'swift-proxy' + end + end diff --git a/manifests/bench.pp b/manifests/bench.pp index 76c6d434..d390c595 100644 --- a/manifests/bench.pp +++ b/manifests/bench.pp @@ -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; diff --git a/manifests/dispersion.pp b/manifests/dispersion.pp index 81f6d677..0fc7ddae 100644 --- a/manifests/dispersion.pp +++ b/manifests/dispersion.pp @@ -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': diff --git a/manifests/init.pp b/manifests/init.pp index eba8f338..82e99610 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -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, diff --git a/spec/classes/swift_bench_spec.rb b/spec/classes/swift_bench_spec.rb index 66c2115e..c278cbd6 100644 --- a/spec/classes/swift_bench_spec.rb +++ b/spec/classes/swift_bench_spec.rb @@ -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]) diff --git a/spec/classes/swift_dispersion_spec.rb b/spec/classes/swift_dispersion_spec.rb index 00235c6b..ffa70a8c 100644 --- a/spec/classes/swift_dispersion_spec.rb +++ b/spec/classes/swift_dispersion_spec.rb @@ -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]) diff --git a/spec/unit/provider/swift_account_config/ini_setting_spec.rb b/spec/unit/provider/swift_account_config/ini_setting_spec.rb new file mode 100644 index 00000000..cfdbdb0e --- /dev/null +++ b/spec/unit/provider/swift_account_config/ini_setting_spec.rb @@ -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 diff --git a/spec/unit/provider/swift_bench_config/ini_setting_spec.rb b/spec/unit/provider/swift_bench_config/ini_setting_spec.rb new file mode 100644 index 00000000..7aa55031 --- /dev/null +++ b/spec/unit/provider/swift_bench_config/ini_setting_spec.rb @@ -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 diff --git a/spec/unit/provider/swift_config/ini_setting_spec.rb b/spec/unit/provider/swift_config/ini_setting_spec.rb new file mode 100644 index 00000000..4500680b --- /dev/null +++ b/spec/unit/provider/swift_config/ini_setting_spec.rb @@ -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 diff --git a/spec/unit/provider/swift_container_config/ini_setting_spec.rb b/spec/unit/provider/swift_container_config/ini_setting_spec.rb new file mode 100644 index 00000000..dd6752b4 --- /dev/null +++ b/spec/unit/provider/swift_container_config/ini_setting_spec.rb @@ -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 diff --git a/spec/unit/provider/swift_dispersion_config/ini_setting_spec.rb b/spec/unit/provider/swift_dispersion_config/ini_setting_spec.rb new file mode 100644 index 00000000..992e9a5a --- /dev/null +++ b/spec/unit/provider/swift_dispersion_config/ini_setting_spec.rb @@ -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 diff --git a/spec/unit/provider/swift_object_config/ini_setting_spec.rb b/spec/unit/provider/swift_object_config/ini_setting_spec.rb new file mode 100644 index 00000000..c356bcd0 --- /dev/null +++ b/spec/unit/provider/swift_object_config/ini_setting_spec.rb @@ -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 diff --git a/spec/unit/provider/swift_proxy_config/ini_setting_spec.rb b/spec/unit/provider/swift_proxy_config/ini_setting_spec.rb new file mode 100644 index 00000000..7893b1b3 --- /dev/null +++ b/spec/unit/provider/swift_proxy_config/ini_setting_spec.rb @@ -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 diff --git a/spec/unit/type/swift_account_config_spec.rb b/spec/unit/type/swift_account_config_spec.rb new file mode 100644 index 00000000..f6a4c632 --- /dev/null +++ b/spec/unit/type/swift_account_config_spec.rb @@ -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 diff --git a/spec/unit/type/swift_bench_config_spec.rb b/spec/unit/type/swift_bench_config_spec.rb new file mode 100644 index 00000000..d3744a19 --- /dev/null +++ b/spec/unit/type/swift_bench_config_spec.rb @@ -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 diff --git a/spec/unit/type/swift_config_spec.rb b/spec/unit/type/swift_config_spec.rb new file mode 100644 index 00000000..d7341be7 --- /dev/null +++ b/spec/unit/type/swift_config_spec.rb @@ -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 diff --git a/spec/unit/type/swift_container_config_spec.rb b/spec/unit/type/swift_container_config_spec.rb new file mode 100644 index 00000000..295f3a84 --- /dev/null +++ b/spec/unit/type/swift_container_config_spec.rb @@ -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 diff --git a/spec/unit/type/swift_dispersion_config_spec.rb b/spec/unit/type/swift_dispersion_config_spec.rb new file mode 100644 index 00000000..292dfa44 --- /dev/null +++ b/spec/unit/type/swift_dispersion_config_spec.rb @@ -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 diff --git a/spec/unit/type/swift_object_config_spec.rb b/spec/unit/type/swift_object_config_spec.rb new file mode 100644 index 00000000..0d6138b0 --- /dev/null +++ b/spec/unit/type/swift_object_config_spec.rb @@ -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 diff --git a/spec/unit/type/swift_proxy_config_spec.rb b/spec/unit/type/swift_proxy_config_spec.rb new file mode 100644 index 00000000..a088e4ad --- /dev/null +++ b/spec/unit/type/swift_proxy_config_spec.rb @@ -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