diff --git a/README.md b/README.md index 98b23500..3c446229 100644 --- a/README.md +++ b/README.md @@ -35,6 +35,120 @@ Implementation trove is a combination of Puppet manifest and ruby code to delivery configuration and extra functionality through types and providers. +### Types + +#### trove_config + +The `trove_config` provider is a children of the ini_setting provider. It allows one to write an entry in the `/etc/trove/trove.conf` file. + +```puppet +trove_config { 'DEFAULT/verbose' : + value => true, +} +``` + +This will write `verbose=true` in the `[DEFAULT]` section. + +##### name + +Section/setting name to manage from `trove.conf` + +##### value + +The value of the setting to be defined. + +##### secret + +Whether to hide the value from Puppet logs. Defaults to `false`. + +##### ensure_absent_val + +If value is equal to ensure_absent_val then the resource will behave as if `ensure => absent` was specified. Defaults to `` + +#### trove_conductor_config + +The `trove_conductor_config` provider is a children of the ini_setting provider. It allows one to write an entry in the `/etc/trove/trove-conductor.conf` file. + +```puppet +trove_conductor_config { 'DEFAULT/verbose' : + value => true, +} +``` + +This will write `verbose=true` in the `[DEFAULT]` section. + +##### name + +Section/setting name to manage from `trove.conf` + +##### value + +The value of the setting to be defined. + +##### secret + +Whether to hide the value from Puppet logs. Defaults to `false`. + +##### ensure_absent_val + +If value is equal to ensure_absent_val then the resource will behave as if `ensure => absent` was specified. Defaults to `` + +#### trove_guestagent_config + +The `trove_guestagent_config` provider is a children of the ini_setting provider. It allows one to write an entry in the `/etc/trove/trove-guestagent.conf` file. + +```puppet +trove_guestagent_config { 'DEFAULT/verbose' : + value => true, +} +``` + +This will write `verbose=true` in the `[DEFAULT]` section. + +##### name + +Section/setting name to manage from `trove.conf` + +##### value + +The value of the setting to be defined. + +##### secret + +Whether to hide the value from Puppet logs. Defaults to `false`. + +##### ensure_absent_val + +If value is equal to ensure_absent_val then the resource will behave as if `ensure => absent` was specified. Defaults to `` + +#### trove_taskmanager_config + +The `trove_taskmanager_config` provider is a children of the ini_setting provider. It allows one to write an entry in the `/etc/trove/trove-taskmanager.conf` file. + +```puppet +trove_taskmanager_config { 'DEFAULT/verbose' : + value => true, +} +``` + +This will write `verbose=true` in the `[DEFAULT]` section. + +##### name + +Section/setting name to manage from `trove.conf` + +##### value + +The value of the setting to be defined. + +##### secret + +Whether to hide the value from Puppet logs. Defaults to `false`. + +##### ensure_absent_val + +If value is equal to ensure_absent_val then the resource will behave as if `ensure => absent` was specified. Defaults to `` + Limitations ----------- diff --git a/lib/puppet/provider/trove_api_paste_ini/ini_setting.rb b/lib/puppet/provider/trove_api_paste_ini/ini_setting.rb index e63fd1ee..236f34f3 100644 --- a/lib/puppet/provider/trove_api_paste_ini/ini_setting.rb +++ b/lib/puppet/provider/trove_api_paste_ini/ini_setting.rb @@ -1,27 +1,10 @@ Puppet::Type.type(:trove_api_paste_ini).provide( :ini_setting, - :parent => Puppet::Type.type(:ini_setting).provider(:ruby) + :parent => Puppet::Type.type(:openstack_config).provider(:ini_setting) ) do - def section - resource[:name].split('/', 2).first - end - - def setting - resource[:name].split('/', 2).last - end - - def separator - '=' - end - def self.file_path '/etc/trove/api-paste.ini' end - # added for backwards compatibility with older versions of inifile - def file_path - self.class.file_path - end - end diff --git a/lib/puppet/provider/trove_conductor_config/ini_setting.rb b/lib/puppet/provider/trove_conductor_config/ini_setting.rb index a4a0f886..bcf6aaeb 100644 --- a/lib/puppet/provider/trove_conductor_config/ini_setting.rb +++ b/lib/puppet/provider/trove_conductor_config/ini_setting.rb @@ -1,27 +1,10 @@ Puppet::Type.type(:trove_conductor_config).provide( :ini_setting, - :parent => Puppet::Type.type(:ini_setting).provider(:ruby) + :parent => Puppet::Type.type(:openstack_config).provider(:ini_setting) ) do - def section - resource[:name].split('/', 2).first - end - - def setting - resource[:name].split('/', 2).last - end - - def separator - '=' - end - def self.file_path '/etc/trove/trove-conductor.conf' end - # added for backwards compatibility with older versions of inifile - def file_path - self.class.file_path - end - end diff --git a/lib/puppet/provider/trove_config/ini_setting.rb b/lib/puppet/provider/trove_config/ini_setting.rb index d71365c9..5698071c 100644 --- a/lib/puppet/provider/trove_config/ini_setting.rb +++ b/lib/puppet/provider/trove_config/ini_setting.rb @@ -1,27 +1,10 @@ Puppet::Type.type(:trove_config).provide( :ini_setting, - :parent => Puppet::Type.type(:ini_setting).provider(:ruby) + :parent => Puppet::Type.type(:openstack_config).provider(:ini_setting) ) do - def section - resource[:name].split('/', 2).first - end - - def setting - resource[:name].split('/', 2).last - end - - def separator - '=' - end - def self.file_path '/etc/trove/trove.conf' end - # added for backwards compatibility with older versions of inifile - def file_path - self.class.file_path - end - end diff --git a/lib/puppet/provider/trove_guestagent_config/ini_setting.rb b/lib/puppet/provider/trove_guestagent_config/ini_setting.rb index d527f3e1..4d814986 100644 --- a/lib/puppet/provider/trove_guestagent_config/ini_setting.rb +++ b/lib/puppet/provider/trove_guestagent_config/ini_setting.rb @@ -1,27 +1,10 @@ Puppet::Type.type(:trove_guestagent_config).provide( :ini_setting, - :parent => Puppet::Type.type(:ini_setting).provider(:ruby) + :parent => Puppet::Type.type(:openstack_config).provider(:ini_setting) ) do - def section - resource[:name].split('/', 2).first - end - - def setting - resource[:name].split('/', 2).last - end - - def separator - '=' - end - def self.file_path '/etc/trove/trove-guestagent.conf' end - # added for backwards compatibility with older versions of inifile - def file_path - self.class.file_path - end - end diff --git a/lib/puppet/provider/trove_taskmanager_config/ini_setting.rb b/lib/puppet/provider/trove_taskmanager_config/ini_setting.rb index 5aa95396..9e6c1d3b 100644 --- a/lib/puppet/provider/trove_taskmanager_config/ini_setting.rb +++ b/lib/puppet/provider/trove_taskmanager_config/ini_setting.rb @@ -1,27 +1,10 @@ Puppet::Type.type(:trove_taskmanager_config).provide( :ini_setting, - :parent => Puppet::Type.type(:ini_setting).provider(:ruby) + :parent => Puppet::Type.type(:openstack_config).provider(:ini_setting) ) do - def section - resource[:name].split('/', 2).first - end - - def setting - resource[:name].split('/', 2).last - end - - def separator - '=' - end - def self.file_path '/etc/trove/trove-taskmanager.conf' end - # added for backwards compatibility with older versions of inifile - def file_path - self.class.file_path - end - end diff --git a/lib/puppet/type/trove_api_paste_ini.rb b/lib/puppet/type/trove_api_paste_ini.rb index 1ff1a5b5..ae7c6d3d 100644 --- a/lib/puppet/type/trove_api_paste_ini.rb +++ b/lib/puppet/type/trove_api_paste_ini.rb @@ -39,4 +39,10 @@ Puppet::Type.newtype(:trove_api_paste_ini) do defaultto false end + + newparam(:ensure_absent_val) do + desc 'A value that is specified as the value property will behave as if ensure => absent was specified' + defaultto('') + end + end diff --git a/lib/puppet/type/trove_conductor_config.rb b/lib/puppet/type/trove_conductor_config.rb index 6450a476..b790a3b1 100644 --- a/lib/puppet/type/trove_conductor_config.rb +++ b/lib/puppet/type/trove_conductor_config.rb @@ -14,6 +14,7 @@ Puppet::Type.newtype(:trove_conductor_config) do value.capitalize! if value =~ /^(true|false)$/i value end + newvalues(/^[\S ]*$/) def is_to_s( currentvalue ) if resource.secret? @@ -39,4 +40,10 @@ Puppet::Type.newtype(:trove_conductor_config) do defaultto false end + + newparam(:ensure_absent_val) do + desc 'A value that is specified as the value property will behave as if ensure => absent was specified' + defaultto('') + end + end diff --git a/lib/puppet/type/trove_config.rb b/lib/puppet/type/trove_config.rb index f1d14d21..b3bcce4a 100644 --- a/lib/puppet/type/trove_config.rb +++ b/lib/puppet/type/trove_config.rb @@ -14,6 +14,7 @@ Puppet::Type.newtype(:trove_config) do value.capitalize! if value =~ /^(true|false)$/i value end + newvalues(/^[\S ]*$/) def is_to_s( currentvalue ) if resource.secret? @@ -39,4 +40,10 @@ Puppet::Type.newtype(:trove_config) do defaultto false end + + newparam(:ensure_absent_val) do + desc 'A value that is specified as the value property will behave as if ensure => absent was specified' + defaultto('') + end + end diff --git a/lib/puppet/type/trove_guestagent_config.rb b/lib/puppet/type/trove_guestagent_config.rb index 06072f8c..dff561e6 100644 --- a/lib/puppet/type/trove_guestagent_config.rb +++ b/lib/puppet/type/trove_guestagent_config.rb @@ -14,6 +14,7 @@ Puppet::Type.newtype(:trove_guestagent_config) do value.capitalize! if value =~ /^(true|false)$/i value end + newvalues(/^[\S ]*$/) def is_to_s( currentvalue ) if resource.secret? @@ -39,4 +40,10 @@ Puppet::Type.newtype(:trove_guestagent_config) do defaultto false end + + newparam(:ensure_absent_val) do + desc 'A value that is specified as the value property will behave as if ensure => absent was specified' + defaultto('') + end + end diff --git a/lib/puppet/type/trove_taskmanager_config.rb b/lib/puppet/type/trove_taskmanager_config.rb index 25af3765..88480c5e 100644 --- a/lib/puppet/type/trove_taskmanager_config.rb +++ b/lib/puppet/type/trove_taskmanager_config.rb @@ -14,6 +14,7 @@ Puppet::Type.newtype(:trove_taskmanager_config) do value.capitalize! if value =~ /^(true|false)$/i value end + newvalues(/^[\S ]*$/) def is_to_s( currentvalue ) if resource.secret? @@ -39,4 +40,10 @@ Puppet::Type.newtype(:trove_taskmanager_config) do defaultto false end + + newparam(:ensure_absent_val) do + desc 'A value that is specified as the value property will behave as if ensure => absent was specified' + defaultto('') + end + end diff --git a/spec/unit/provider/trove_config/ini_setting_spec.rb b/spec/unit/provider/trove_config/ini_setting_spec.rb index 239dc6f5..8b9fb3df 100644 --- a/spec/unit/provider/trove_config/ini_setting_spec.rb +++ b/spec/unit/provider/trove_config/ini_setting_spec.rb @@ -13,6 +13,17 @@ $LOAD_PATH.push( 'inifile', 'lib') ) +$LOAD_PATH.push( + File.join( + File.dirname(__FILE__), + '..', + '..', + '..', + 'fixtures', + 'modules', + 'openstacklib', + 'lib') +) require 'spec_helper' provider_class = Puppet::Type.type(:trove_config).provider(:ini_setting) describe provider_class do @@ -34,4 +45,23 @@ describe provider_class do expect(provider.section).to eq('dude') expect(provider.setting).to eq('foo') end + + it 'should ensure absent when is specified as a value' do + resource = Puppet::Type::Trove_config.new( + {:name => 'dude/foo', :value => ''} + ) + provider = provider_class.new(resource) + provider.exists? + expect(resource[:ensure]).to eq :absent + end + + it 'should ensure absent when value matches ensure_absent_val' do + resource = Puppet::Type::Trove_config.new( + {:name => 'dude/foo', :value => 'foo', :ensure_absent_val => 'foo' } + ) + provider = provider_class.new(resource) + provider.exists? + expect(resource[:ensure]).to eq :absent + end + end