Merge "Reflect provider change in puppet-openstacklib"
This commit is contained in:
30
README.md
30
README.md
@@ -68,6 +68,36 @@ Implementation
|
||||
|
||||
nova is a combination of Puppet manifest and ruby code to delivery configuration and extra functionality through types and providers.
|
||||
|
||||
### Types
|
||||
|
||||
#### nova_config
|
||||
|
||||
The `nova_config` provider is a children of the ini_setting provider. It allows one to write an entry in the `/etc/nova/nova.conf` file.
|
||||
|
||||
```puppet
|
||||
nova_config { 'DEFAULT/verbose' :
|
||||
value => true,
|
||||
}
|
||||
```
|
||||
|
||||
This will write `verbose=true` in the `[DEFAULT]` section.
|
||||
|
||||
##### name
|
||||
|
||||
Section/setting name to manage from `nova.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
|
||||
-----------
|
||||
|
||||
|
@@ -1,32 +1,10 @@
|
||||
Puppet::Type.type(:nova_config).provide(
|
||||
:ini_setting,
|
||||
:parent => Puppet::Type.type(:ini_setting).provider(:ruby)
|
||||
:parent => Puppet::Type.type(:openstack_config).provider(:ini_setting)
|
||||
) do
|
||||
|
||||
# the setting is always default
|
||||
# this if for backwards compat with the old puppet providers for nova_config
|
||||
def section
|
||||
resource[:name].split('/', 2)[0]
|
||||
end
|
||||
|
||||
# assumes that the name was the setting
|
||||
# this is to maintain backwards compat with the the older
|
||||
# stuff
|
||||
def setting
|
||||
resource[:name].split('/', 2)[1]
|
||||
end
|
||||
|
||||
def separator
|
||||
'='
|
||||
end
|
||||
|
||||
def self.file_path
|
||||
'/etc/nova/nova.conf'
|
||||
end
|
||||
|
||||
# this needs to be removed. This has been replaced with the class method
|
||||
def file_path
|
||||
self.class.file_path
|
||||
end
|
||||
|
||||
end
|
||||
|
@@ -3,6 +3,7 @@ Puppet::Type.newtype(:nova_config) do
|
||||
ensurable
|
||||
|
||||
newparam(:name, :namevar => true) do
|
||||
desc 'Section/setting name to manage from nova.conf'
|
||||
newvalues(/\S+\/\S+/)
|
||||
end
|
||||
|
||||
@@ -40,6 +41,11 @@ Puppet::Type.newtype(:nova_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('<SERVICE DEFAULT>')
|
||||
end
|
||||
|
||||
autorequire(:package) do
|
||||
'nova-common'
|
||||
end
|
||||
|
@@ -14,6 +14,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(:nova_config).provider(:ini_setting)
|
||||
describe provider_class do
|
||||
@@ -35,4 +46,23 @@ describe provider_class do
|
||||
expect(provider.section).to eq('dude')
|
||||
expect(provider.setting).to eq('foo')
|
||||
end
|
||||
|
||||
it 'should ensure absent when <SERVICE DEFAULT> is specified as a value' do
|
||||
resource = Puppet::Type::Nova_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::Nova_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
|
||||
|
Reference in New Issue
Block a user