diff --git a/README.md b/README.md index ce38bab..dc0ee7a 100644 --- a/README.md +++ b/README.md @@ -35,6 +35,36 @@ Implementation tuskar is a combination of Puppet manifest and ruby code to delivery configuration and extra functionality through types and providers. +### Types + +#### tuskar_config + +The `tuskar_config` provider is a children of the ini_setting provider. It allows one to write an entry in the `/etc/tuskar/tuskar.conf` file. + +```puppet +tuskar_config { 'DEFAULT/verbose' : + value => true, +} +``` + +This will write `verbose=true` in the `[DEFAULT]` section. + +##### name + +Section/setting name to manage from `tuskar.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/tuskar_config/ini_setting.rb b/lib/puppet/provider/tuskar_config/ini_setting.rb index 4bd0867..a1d59c1 100644 --- a/lib/puppet/provider/tuskar_config/ini_setting.rb +++ b/lib/puppet/provider/tuskar_config/ini_setting.rb @@ -1,27 +1,10 @@ Puppet::Type.type(:tuskar_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/tuskar/tuskar.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/tuskar_config.rb b/lib/puppet/type/tuskar_config.rb index d78cc9e..f61139c 100644 --- a/lib/puppet/type/tuskar_config.rb +++ b/lib/puppet/type/tuskar_config.rb @@ -3,7 +3,7 @@ Puppet::Type.newtype(:tuskar_config) do ensurable newparam(:name, :namevar => true) do - desc 'Section/setting name to manage from /etc/tuskar/tuskar.conf' + desc 'Section/setting name to manage from tuskar.conf' newvalues(/\S+\/\S+/) end @@ -14,6 +14,7 @@ Puppet::Type.newtype(:tuskar_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(:tuskar_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