diff --git a/README.md b/README.md index 78fc04dec..28e53a790 100644 --- a/README.md +++ b/README.md @@ -138,6 +138,36 @@ Implementation keystone is a combination of Puppet manifest and ruby code to delivery configuration and extra functionality through types and providers. +### Types + +#### keystone_config + +The `keystone_config` provider is a children of the ini_setting provider. It allows one to write an entry in the `/etc/keystone/keystone.conf` file. + +```puppet +keystone_config { 'DEFAULT/verbose' : + value => true, +} +``` + +This will write `verbose=true` in the `[DEFAULT]` section. + +##### name + +Section/setting name to manage from `keystone.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/keystone_config/ini_setting.rb b/lib/puppet/provider/keystone_config/ini_setting.rb index 4d7b5cbdb..3c2b1d272 100644 --- a/lib/puppet/provider/keystone_config/ini_setting.rb +++ b/lib/puppet/provider/keystone_config/ini_setting.rb @@ -1,27 +1,10 @@ Puppet::Type.type(:keystone_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/keystone/keystone.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/keystone_config.rb b/lib/puppet/type/keystone_config.rb index 0326c1d47..bc416ef0f 100644 --- a/lib/puppet/type/keystone_config.rb +++ b/lib/puppet/type/keystone_config.rb @@ -41,6 +41,11 @@ Puppet::Type.newtype(:keystone_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 + autorequire(:package) do 'keystone' end diff --git a/spec/unit/provider/keystone_config/ini_setting_spec.rb b/spec/unit/provider/keystone_config/ini_setting_spec.rb index 8638f0547..8a9e32ee8 100644 --- a/spec/unit/provider/keystone_config/ini_setting_spec.rb +++ b/spec/unit/provider/keystone_config/ini_setting_spec.rb @@ -36,4 +36,22 @@ describe provider_class do expect(provider.setting).to eq('foo') end + it 'should ensure absent when is specified as a value' do + resource = Puppet::Type::Keystone_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::Keystone_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