Reflect provider change in puppet-openstacklib
With the creation of the new openstack_config provider, some processing that was done in trove_config has been centralized in openstack_config. The same apply for trove_conductor_config, trove_guestagent_config and trove_taskmanager_config Impacted methods are : * section * setting * separator Also, this commit adds the fact that, when passing a specific string (ensure_absent_val) the provider will behave as if ensure => absent was specified. '<SERVICE DEFAULT>' is the default value for ensure_absent_val. The use case is the following : trove_config { 'DEFAULT/foo' : value => 'bar' } # will work as usual trove_config { 'DEFAULT/foo' : value => '<SERVICE DEFAULT>' } # will mean absent That means that all the current : if $myvar { trove_config { 'DEFAULT/foo' : value => $myvar } } else { trove_config { 'DEFAULT/foo' : ensure => absent } } can be removed in favor of : trove_config { 'DEFAULT/foo' : value => $myvar } If for any reason '<SERVICE DEFAULT>' turns out to be a valid value for a specific parameter. One could by pass that doing the following : trove_config { 'DEFAULT/foo' : value => '<SERVICE DEFAULT>', ensure_absent_val => 'foo' } Change-Id: I44472b107c951d22932c533031f68aa67a5f2e18 Depends-On: I0eeebde3aac2662cc7e69bfad7f8d2481463a218
This commit is contained in:
parent
27313c16bc
commit
c8527beace
114
README.md
114
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.
|
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 `<SERVICE DEFAULT>`
|
||||||
|
|
||||||
|
#### 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 `<SERVICE DEFAULT>`
|
||||||
|
|
||||||
|
#### 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 `<SERVICE DEFAULT>`
|
||||||
|
|
||||||
|
#### 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 `<SERVICE DEFAULT>`
|
||||||
|
|
||||||
Limitations
|
Limitations
|
||||||
-----------
|
-----------
|
||||||
|
|
||||||
|
@ -1,27 +1,10 @@
|
|||||||
Puppet::Type.type(:trove_api_paste_ini).provide(
|
Puppet::Type.type(:trove_api_paste_ini).provide(
|
||||||
:ini_setting,
|
:ini_setting,
|
||||||
:parent => Puppet::Type.type(:ini_setting).provider(:ruby)
|
:parent => Puppet::Type.type(:openstack_config).provider(:ini_setting)
|
||||||
) do
|
) do
|
||||||
|
|
||||||
def section
|
|
||||||
resource[:name].split('/', 2).first
|
|
||||||
end
|
|
||||||
|
|
||||||
def setting
|
|
||||||
resource[:name].split('/', 2).last
|
|
||||||
end
|
|
||||||
|
|
||||||
def separator
|
|
||||||
'='
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.file_path
|
def self.file_path
|
||||||
'/etc/trove/api-paste.ini'
|
'/etc/trove/api-paste.ini'
|
||||||
end
|
end
|
||||||
|
|
||||||
# added for backwards compatibility with older versions of inifile
|
|
||||||
def file_path
|
|
||||||
self.class.file_path
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -1,27 +1,10 @@
|
|||||||
Puppet::Type.type(:trove_conductor_config).provide(
|
Puppet::Type.type(:trove_conductor_config).provide(
|
||||||
:ini_setting,
|
:ini_setting,
|
||||||
:parent => Puppet::Type.type(:ini_setting).provider(:ruby)
|
:parent => Puppet::Type.type(:openstack_config).provider(:ini_setting)
|
||||||
) do
|
) do
|
||||||
|
|
||||||
def section
|
|
||||||
resource[:name].split('/', 2).first
|
|
||||||
end
|
|
||||||
|
|
||||||
def setting
|
|
||||||
resource[:name].split('/', 2).last
|
|
||||||
end
|
|
||||||
|
|
||||||
def separator
|
|
||||||
'='
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.file_path
|
def self.file_path
|
||||||
'/etc/trove/trove-conductor.conf'
|
'/etc/trove/trove-conductor.conf'
|
||||||
end
|
end
|
||||||
|
|
||||||
# added for backwards compatibility with older versions of inifile
|
|
||||||
def file_path
|
|
||||||
self.class.file_path
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -1,27 +1,10 @@
|
|||||||
Puppet::Type.type(:trove_config).provide(
|
Puppet::Type.type(:trove_config).provide(
|
||||||
:ini_setting,
|
:ini_setting,
|
||||||
:parent => Puppet::Type.type(:ini_setting).provider(:ruby)
|
:parent => Puppet::Type.type(:openstack_config).provider(:ini_setting)
|
||||||
) do
|
) do
|
||||||
|
|
||||||
def section
|
|
||||||
resource[:name].split('/', 2).first
|
|
||||||
end
|
|
||||||
|
|
||||||
def setting
|
|
||||||
resource[:name].split('/', 2).last
|
|
||||||
end
|
|
||||||
|
|
||||||
def separator
|
|
||||||
'='
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.file_path
|
def self.file_path
|
||||||
'/etc/trove/trove.conf'
|
'/etc/trove/trove.conf'
|
||||||
end
|
end
|
||||||
|
|
||||||
# added for backwards compatibility with older versions of inifile
|
|
||||||
def file_path
|
|
||||||
self.class.file_path
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -1,27 +1,10 @@
|
|||||||
Puppet::Type.type(:trove_guestagent_config).provide(
|
Puppet::Type.type(:trove_guestagent_config).provide(
|
||||||
:ini_setting,
|
:ini_setting,
|
||||||
:parent => Puppet::Type.type(:ini_setting).provider(:ruby)
|
:parent => Puppet::Type.type(:openstack_config).provider(:ini_setting)
|
||||||
) do
|
) do
|
||||||
|
|
||||||
def section
|
|
||||||
resource[:name].split('/', 2).first
|
|
||||||
end
|
|
||||||
|
|
||||||
def setting
|
|
||||||
resource[:name].split('/', 2).last
|
|
||||||
end
|
|
||||||
|
|
||||||
def separator
|
|
||||||
'='
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.file_path
|
def self.file_path
|
||||||
'/etc/trove/trove-guestagent.conf'
|
'/etc/trove/trove-guestagent.conf'
|
||||||
end
|
end
|
||||||
|
|
||||||
# added for backwards compatibility with older versions of inifile
|
|
||||||
def file_path
|
|
||||||
self.class.file_path
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -1,27 +1,10 @@
|
|||||||
Puppet::Type.type(:trove_taskmanager_config).provide(
|
Puppet::Type.type(:trove_taskmanager_config).provide(
|
||||||
:ini_setting,
|
:ini_setting,
|
||||||
:parent => Puppet::Type.type(:ini_setting).provider(:ruby)
|
:parent => Puppet::Type.type(:openstack_config).provider(:ini_setting)
|
||||||
) do
|
) do
|
||||||
|
|
||||||
def section
|
|
||||||
resource[:name].split('/', 2).first
|
|
||||||
end
|
|
||||||
|
|
||||||
def setting
|
|
||||||
resource[:name].split('/', 2).last
|
|
||||||
end
|
|
||||||
|
|
||||||
def separator
|
|
||||||
'='
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.file_path
|
def self.file_path
|
||||||
'/etc/trove/trove-taskmanager.conf'
|
'/etc/trove/trove-taskmanager.conf'
|
||||||
end
|
end
|
||||||
|
|
||||||
# added for backwards compatibility with older versions of inifile
|
|
||||||
def file_path
|
|
||||||
self.class.file_path
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -39,4 +39,10 @@ Puppet::Type.newtype(:trove_api_paste_ini) do
|
|||||||
|
|
||||||
defaultto false
|
defaultto false
|
||||||
end
|
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('<SERVICE DEFAULT>')
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -14,6 +14,7 @@ Puppet::Type.newtype(:trove_conductor_config) do
|
|||||||
value.capitalize! if value =~ /^(true|false)$/i
|
value.capitalize! if value =~ /^(true|false)$/i
|
||||||
value
|
value
|
||||||
end
|
end
|
||||||
|
newvalues(/^[\S ]*$/)
|
||||||
|
|
||||||
def is_to_s( currentvalue )
|
def is_to_s( currentvalue )
|
||||||
if resource.secret?
|
if resource.secret?
|
||||||
@ -39,4 +40,10 @@ Puppet::Type.newtype(:trove_conductor_config) do
|
|||||||
|
|
||||||
defaultto false
|
defaultto false
|
||||||
end
|
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('<SERVICE DEFAULT>')
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -14,6 +14,7 @@ Puppet::Type.newtype(:trove_config) do
|
|||||||
value.capitalize! if value =~ /^(true|false)$/i
|
value.capitalize! if value =~ /^(true|false)$/i
|
||||||
value
|
value
|
||||||
end
|
end
|
||||||
|
newvalues(/^[\S ]*$/)
|
||||||
|
|
||||||
def is_to_s( currentvalue )
|
def is_to_s( currentvalue )
|
||||||
if resource.secret?
|
if resource.secret?
|
||||||
@ -39,4 +40,10 @@ Puppet::Type.newtype(:trove_config) do
|
|||||||
|
|
||||||
defaultto false
|
defaultto false
|
||||||
end
|
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('<SERVICE DEFAULT>')
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -14,6 +14,7 @@ Puppet::Type.newtype(:trove_guestagent_config) do
|
|||||||
value.capitalize! if value =~ /^(true|false)$/i
|
value.capitalize! if value =~ /^(true|false)$/i
|
||||||
value
|
value
|
||||||
end
|
end
|
||||||
|
newvalues(/^[\S ]*$/)
|
||||||
|
|
||||||
def is_to_s( currentvalue )
|
def is_to_s( currentvalue )
|
||||||
if resource.secret?
|
if resource.secret?
|
||||||
@ -39,4 +40,10 @@ Puppet::Type.newtype(:trove_guestagent_config) do
|
|||||||
|
|
||||||
defaultto false
|
defaultto false
|
||||||
end
|
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('<SERVICE DEFAULT>')
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -14,6 +14,7 @@ Puppet::Type.newtype(:trove_taskmanager_config) do
|
|||||||
value.capitalize! if value =~ /^(true|false)$/i
|
value.capitalize! if value =~ /^(true|false)$/i
|
||||||
value
|
value
|
||||||
end
|
end
|
||||||
|
newvalues(/^[\S ]*$/)
|
||||||
|
|
||||||
def is_to_s( currentvalue )
|
def is_to_s( currentvalue )
|
||||||
if resource.secret?
|
if resource.secret?
|
||||||
@ -39,4 +40,10 @@ Puppet::Type.newtype(:trove_taskmanager_config) do
|
|||||||
|
|
||||||
defaultto false
|
defaultto false
|
||||||
end
|
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('<SERVICE DEFAULT>')
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -13,6 +13,17 @@ $LOAD_PATH.push(
|
|||||||
'inifile',
|
'inifile',
|
||||||
'lib')
|
'lib')
|
||||||
)
|
)
|
||||||
|
$LOAD_PATH.push(
|
||||||
|
File.join(
|
||||||
|
File.dirname(__FILE__),
|
||||||
|
'..',
|
||||||
|
'..',
|
||||||
|
'..',
|
||||||
|
'fixtures',
|
||||||
|
'modules',
|
||||||
|
'openstacklib',
|
||||||
|
'lib')
|
||||||
|
)
|
||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
provider_class = Puppet::Type.type(:trove_config).provider(:ini_setting)
|
provider_class = Puppet::Type.type(:trove_config).provider(:ini_setting)
|
||||||
describe provider_class do
|
describe provider_class do
|
||||||
@ -34,4 +45,23 @@ describe provider_class do
|
|||||||
expect(provider.section).to eq('dude')
|
expect(provider.section).to eq('dude')
|
||||||
expect(provider.setting).to eq('foo')
|
expect(provider.setting).to eq('foo')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'should ensure absent when <SERVICE DEFAULT> is specified as a value' do
|
||||||
|
resource = Puppet::Type::Trove_config.new(
|
||||||
|
{:name => 'dude/foo', :value => '<SERVICE DEFAULT>'}
|
||||||
|
)
|
||||||
|
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
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user