
This commit aims to add a new feature for the ini_setting provider, this feature aims to simulate the ensure => absent behavior when a specific keyword is specified. Currently a pattern we have is if $myvar { keystone_config { 'SECTION/setting' : value => $myvar } } else { keystone_config { 'SECTION/setting' : ensure => absent } } If one has dozens or hundreds of parameters to handle then it can easily make the manifest hard to read. The solution offer here would turn the above example in something like Keystone_config { ensure_absent_val = '<SERVICE DEFAULT>' # It is the default } keystone_config { 'SECTION/setting' : value => $myvar } If `$myvar` is '<SERVICE DEFAULT>' then it will act as if `ensure => absent` would have been specified. Also added new tests for openstack_config provider Co-Authored-By: Denis Egorenko <degorenko@mirantis.com> Change-Id: I0eeebde3aac2662cc7e69bfad7f8d2481463a218
34 lines
515 B
Ruby
34 lines
515 B
Ruby
Puppet::Type.type(:openstack_config).provide(
|
|
:ini_setting,
|
|
:parent => Puppet::Type.type(:ini_setting).provider(:ruby)
|
|
) do
|
|
|
|
def exists?
|
|
if resource[:value] == ensure_absent_val
|
|
resource[:ensure] = :absent
|
|
end
|
|
super
|
|
end
|
|
|
|
def section
|
|
resource[:name].split('/', 2).first
|
|
end
|
|
|
|
def setting
|
|
resource[:name].split('/', 2).last
|
|
end
|
|
|
|
def ensure_absent_val
|
|
resource[:ensure_absent_val]
|
|
end
|
|
|
|
def separator
|
|
'='
|
|
end
|
|
|
|
def file_path
|
|
self.class.file_path
|
|
end
|
|
|
|
end
|