Add ini_setting based custom types for configs
Previous configuration file management method used templates. This method had limited flexibility and was cumbersome to use and maintain between upstream versions. This change introduces new custom types based on ini_setting: * swift_account_config: /etc/swift/account-server.conf * swift_bench_config: /etc/swift/swift-bench.conf * swift_config: /etc/swift/swift.conf * swift_container_config: /etc/swift/container-server.conf * swift_dispersion_config: /etc/swift/dispersion.conf * swift_object_config: /etc/swift/object-server.conf * swift_proxy_config: /etc/swift/proxy-server.conf The use of ini_setting offers multiple advantages: * Ability to individually manage configuration settings without the need to modify templates. This allows the user to manage or override settings that aren't handled by the module. * Use upstream default values if none is provided. * Remove the need to maintain and synchronize templates to match upstream versions. Such maintenance could become problematic and complicated if multiple upstream versions are supported but have different base configuration files. Implements: blueprint puppet-swift-ini-settings Change-Id: Iba7be64581b81b8ab4f33cf7096df37e64ccc4b4
This commit is contained in:
parent
503d3e41c0
commit
e41a552afe
.fixtures.ymlModulefile
lib/puppet
provider
swift_account_config
swift_bench_config
swift_config
swift_container_config
swift_dispersion_config
swift_object_config
swift_proxy_config
type
@ -3,6 +3,7 @@ fixtures:
|
||||
"apt": "git://github.com/puppetlabs/puppetlabs-apt.git"
|
||||
"concat": "git://github.com/ripienaar/puppet-concat.git"
|
||||
"create_resources": "git://github.com/puppetlabs/puppetlabs-create_resources.git"
|
||||
"inifile": "git://github.com/cprice-puppet/puppetlabs-inifile"
|
||||
"keystone": "git://github.com/stackforge/puppet-keystone.git"
|
||||
"memcached": "git://github.com/saz/puppet-memcached.git"
|
||||
"rsync": "git://github.com/puppetlabs/puppetlabs-rsync.git"
|
||||
|
@ -8,6 +8,7 @@ description 'Puppet module to install and configure the OpenStack Swift object s
|
||||
project_page 'https://launchpad.net/puppet-openstack'
|
||||
|
||||
## Add dependencies, if any:
|
||||
dependency 'cprice404/inifile', '>= 0.10.3'
|
||||
dependency 'puppetlabs/keystone', '>= 2.0.0'
|
||||
dependency 'puppetlabs/mysql','>= 0.6.1'
|
||||
dependency 'puppetlabs/rsync', '>= 0.1.0'
|
||||
|
27
lib/puppet/provider/swift_account_config/ini_setting.rb
Normal file
27
lib/puppet/provider/swift_account_config/ini_setting.rb
Normal file
@ -0,0 +1,27 @@
|
||||
Puppet::Type.type(:swift_account_config).provide(
|
||||
:ini_setting,
|
||||
:parent => Puppet::Type.type(:ini_setting).provider(:ruby)
|
||||
) 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/swift/account-server.conf'
|
||||
end
|
||||
|
||||
# added for backwards compatibility with older versions of inifile
|
||||
def file_path
|
||||
self.class.file_path
|
||||
end
|
||||
|
||||
end
|
27
lib/puppet/provider/swift_bench_config/ini_setting.rb
Normal file
27
lib/puppet/provider/swift_bench_config/ini_setting.rb
Normal file
@ -0,0 +1,27 @@
|
||||
Puppet::Type.type(:swift_bench_config).provide(
|
||||
:ini_setting,
|
||||
:parent => Puppet::Type.type(:ini_setting).provider(:ruby)
|
||||
) 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/swift/swift-bench.conf'
|
||||
end
|
||||
|
||||
# added for backwards compatibility with older versions of inifile
|
||||
def file_path
|
||||
self.class.file_path
|
||||
end
|
||||
|
||||
end
|
27
lib/puppet/provider/swift_config/ini_setting.rb
Normal file
27
lib/puppet/provider/swift_config/ini_setting.rb
Normal file
@ -0,0 +1,27 @@
|
||||
Puppet::Type.type(:swift_config).provide(
|
||||
:ini_setting,
|
||||
:parent => Puppet::Type.type(:ini_setting).provider(:ruby)
|
||||
) 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/swift/swift.conf'
|
||||
end
|
||||
|
||||
# added for backwards compatibility with older versions of inifile
|
||||
def file_path
|
||||
self.class.file_path
|
||||
end
|
||||
|
||||
end
|
27
lib/puppet/provider/swift_container_config/ini_setting.rb
Normal file
27
lib/puppet/provider/swift_container_config/ini_setting.rb
Normal file
@ -0,0 +1,27 @@
|
||||
Puppet::Type.type(:swift_container_config).provide(
|
||||
:ini_setting,
|
||||
:parent => Puppet::Type.type(:ini_setting).provider(:ruby)
|
||||
) 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/swift/container-server.conf'
|
||||
end
|
||||
|
||||
# added for backwards compatibility with older versions of inifile
|
||||
def file_path
|
||||
self.class.file_path
|
||||
end
|
||||
|
||||
end
|
27
lib/puppet/provider/swift_dispersion_config/ini_setting.rb
Normal file
27
lib/puppet/provider/swift_dispersion_config/ini_setting.rb
Normal file
@ -0,0 +1,27 @@
|
||||
Puppet::Type.type(:swift_dispersion_config).provide(
|
||||
:ini_setting,
|
||||
:parent => Puppet::Type.type(:ini_setting).provider(:ruby)
|
||||
) 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/swift/dispersion.conf'
|
||||
end
|
||||
|
||||
# added for backwards compatibility with older versions of inifile
|
||||
def file_path
|
||||
self.class.file_path
|
||||
end
|
||||
|
||||
end
|
27
lib/puppet/provider/swift_object_config/ini_setting.rb
Normal file
27
lib/puppet/provider/swift_object_config/ini_setting.rb
Normal file
@ -0,0 +1,27 @@
|
||||
Puppet::Type.type(:swift_object_config).provide(
|
||||
:ini_setting,
|
||||
:parent => Puppet::Type.type(:ini_setting).provider(:ruby)
|
||||
) 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/swift/object-server.conf'
|
||||
end
|
||||
|
||||
# added for backwards compatibility with older versions of inifile
|
||||
def file_path
|
||||
self.class.file_path
|
||||
end
|
||||
|
||||
end
|
27
lib/puppet/provider/swift_proxy_config/ini_setting.rb
Normal file
27
lib/puppet/provider/swift_proxy_config/ini_setting.rb
Normal file
@ -0,0 +1,27 @@
|
||||
Puppet::Type.type(:swift_proxy_config).provide(
|
||||
:ini_setting,
|
||||
:parent => Puppet::Type.type(:ini_setting).provider(:ruby)
|
||||
) 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/swift/proxy-server.conf'
|
||||
end
|
||||
|
||||
# added for backwards compatibility with older versions of inifile
|
||||
def file_path
|
||||
self.class.file_path
|
||||
end
|
||||
|
||||
end
|
40
lib/puppet/type/swift_account_config.rb
Normal file
40
lib/puppet/type/swift_account_config.rb
Normal file
@ -0,0 +1,40 @@
|
||||
Puppet::Type.newtype(:swift_account_config) do
|
||||
|
||||
ensurable
|
||||
|
||||
newparam(:name, :namevar => true) do
|
||||
desc 'Section/setting name to manage from /etc/swift/account-server.conf'
|
||||
newvalues(/\S+\/\S+/)
|
||||
end
|
||||
|
||||
newproperty(:value) do
|
||||
desc 'The value of the setting to be defined.'
|
||||
munge do |value|
|
||||
value = value.to_s.strip
|
||||
value.capitalize! if value =~ /^(true|false)$/i
|
||||
value
|
||||
end
|
||||
|
||||
def is_to_s( currentvalue )
|
||||
if resource.secret?
|
||||
return '[old secret redacted]'
|
||||
else
|
||||
return currentvalue
|
||||
end
|
||||
end
|
||||
|
||||
def should_to_s( newvalue )
|
||||
if resource.secret?
|
||||
return '[new secret redacted]'
|
||||
else
|
||||
return newvalue
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
newparam(:secret, :boolean => true) do
|
||||
desc 'Whether to hide the value from Puppet logs. Defaults to `false`.'
|
||||
newvalues(:true, :false)
|
||||
defaultto false
|
||||
end
|
||||
end
|
40
lib/puppet/type/swift_bench_config.rb
Normal file
40
lib/puppet/type/swift_bench_config.rb
Normal file
@ -0,0 +1,40 @@
|
||||
Puppet::Type.newtype(:swift_bench_config) do
|
||||
|
||||
ensurable
|
||||
|
||||
newparam(:name, :namevar => true) do
|
||||
desc 'Section/setting name to manage from /etc/swift/swift-bench.conf'
|
||||
newvalues(/\S+\/\S+/)
|
||||
end
|
||||
|
||||
newproperty(:value) do
|
||||
desc 'The value of the setting to be defined.'
|
||||
munge do |value|
|
||||
value = value.to_s.strip
|
||||
value.capitalize! if value =~ /^(true|false)$/i
|
||||
value
|
||||
end
|
||||
|
||||
def is_to_s( currentvalue )
|
||||
if resource.secret?
|
||||
return '[old secret redacted]'
|
||||
else
|
||||
return currentvalue
|
||||
end
|
||||
end
|
||||
|
||||
def should_to_s( newvalue )
|
||||
if resource.secret?
|
||||
return '[new secret redacted]'
|
||||
else
|
||||
return newvalue
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
newparam(:secret, :boolean => true) do
|
||||
desc 'Whether to hide the value from Puppet logs. Defaults to `false`.'
|
||||
newvalues(:true, :false)
|
||||
defaultto false
|
||||
end
|
||||
end
|
40
lib/puppet/type/swift_config.rb
Normal file
40
lib/puppet/type/swift_config.rb
Normal file
@ -0,0 +1,40 @@
|
||||
Puppet::Type.newtype(:swift_config) do
|
||||
|
||||
ensurable
|
||||
|
||||
newparam(:name, :namevar => true) do
|
||||
desc 'Section/setting name to manage from /etc/swift/swift.conf'
|
||||
newvalues(/\S+\/\S+/)
|
||||
end
|
||||
|
||||
newproperty(:value) do
|
||||
desc 'The value of the setting to be defined.'
|
||||
munge do |value|
|
||||
value = value.to_s.strip
|
||||
value.capitalize! if value =~ /^(true|false)$/i
|
||||
value
|
||||
end
|
||||
|
||||
def is_to_s( currentvalue )
|
||||
if resource.secret?
|
||||
return '[old secret redacted]'
|
||||
else
|
||||
return currentvalue
|
||||
end
|
||||
end
|
||||
|
||||
def should_to_s( newvalue )
|
||||
if resource.secret?
|
||||
return '[new secret redacted]'
|
||||
else
|
||||
return newvalue
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
newparam(:secret, :boolean => true) do
|
||||
desc 'Whether to hide the value from Puppet logs. Defaults to `false`.'
|
||||
newvalues(:true, :false)
|
||||
defaultto false
|
||||
end
|
||||
end
|
40
lib/puppet/type/swift_container_config.rb
Normal file
40
lib/puppet/type/swift_container_config.rb
Normal file
@ -0,0 +1,40 @@
|
||||
Puppet::Type.newtype(:swift_container_config) do
|
||||
|
||||
ensurable
|
||||
|
||||
newparam(:name, :namevar => true) do
|
||||
desc 'Section/setting name to manage from /etc/swift/container-server.conf'
|
||||
newvalues(/\S+\/\S+/)
|
||||
end
|
||||
|
||||
newproperty(:value) do
|
||||
desc 'The value of the setting to be defined.'
|
||||
munge do |value|
|
||||
value = value.to_s.strip
|
||||
value.capitalize! if value =~ /^(true|false)$/i
|
||||
value
|
||||
end
|
||||
|
||||
def is_to_s( currentvalue )
|
||||
if resource.secret?
|
||||
return '[old secret redacted]'
|
||||
else
|
||||
return currentvalue
|
||||
end
|
||||
end
|
||||
|
||||
def should_to_s( newvalue )
|
||||
if resource.secret?
|
||||
return '[new secret redacted]'
|
||||
else
|
||||
return newvalue
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
newparam(:secret, :boolean => true) do
|
||||
desc 'Whether to hide the value from Puppet logs. Defaults to `false`.'
|
||||
newvalues(:true, :false)
|
||||
defaultto false
|
||||
end
|
||||
end
|
40
lib/puppet/type/swift_dispersion_config.rb
Normal file
40
lib/puppet/type/swift_dispersion_config.rb
Normal file
@ -0,0 +1,40 @@
|
||||
Puppet::Type.newtype(:swift_dispersion_config) do
|
||||
|
||||
ensurable
|
||||
|
||||
newparam(:name, :namevar => true) do
|
||||
desc 'Section/setting name to manage from /etc/swift/dispersion.conf'
|
||||
newvalues(/\S+\/\S+/)
|
||||
end
|
||||
|
||||
newproperty(:value) do
|
||||
desc 'The value of the setting to be defined.'
|
||||
munge do |value|
|
||||
value = value.to_s.strip
|
||||
value.capitalize! if value =~ /^(true|false)$/i
|
||||
value
|
||||
end
|
||||
|
||||
def is_to_s( currentvalue )
|
||||
if resource.secret?
|
||||
return '[old secret redacted]'
|
||||
else
|
||||
return currentvalue
|
||||
end
|
||||
end
|
||||
|
||||
def should_to_s( newvalue )
|
||||
if resource.secret?
|
||||
return '[new secret redacted]'
|
||||
else
|
||||
return newvalue
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
newparam(:secret, :boolean => true) do
|
||||
desc 'Whether to hide the value from Puppet logs. Defaults to `false`.'
|
||||
newvalues(:true, :false)
|
||||
defaultto false
|
||||
end
|
||||
end
|
40
lib/puppet/type/swift_object_config.rb
Normal file
40
lib/puppet/type/swift_object_config.rb
Normal file
@ -0,0 +1,40 @@
|
||||
Puppet::Type.newtype(:swift_object_config) do
|
||||
|
||||
ensurable
|
||||
|
||||
newparam(:name, :namevar => true) do
|
||||
desc 'Section/setting name to manage from /etc/swift/object-server.conf'
|
||||
newvalues(/\S+\/\S+/)
|
||||
end
|
||||
|
||||
newproperty(:value) do
|
||||
desc 'The value of the setting to be defined.'
|
||||
munge do |value|
|
||||
value = value.to_s.strip
|
||||
value.capitalize! if value =~ /^(true|false)$/i
|
||||
value
|
||||
end
|
||||
|
||||
def is_to_s( currentvalue )
|
||||
if resource.secret?
|
||||
return '[old secret redacted]'
|
||||
else
|
||||
return currentvalue
|
||||
end
|
||||
end
|
||||
|
||||
def should_to_s( newvalue )
|
||||
if resource.secret?
|
||||
return '[new secret redacted]'
|
||||
else
|
||||
return newvalue
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
newparam(:secret, :boolean => true) do
|
||||
desc 'Whether to hide the value from Puppet logs. Defaults to `false`.'
|
||||
newvalues(:true, :false)
|
||||
defaultto false
|
||||
end
|
||||
end
|
40
lib/puppet/type/swift_proxy_config.rb
Normal file
40
lib/puppet/type/swift_proxy_config.rb
Normal file
@ -0,0 +1,40 @@
|
||||
Puppet::Type.newtype(:swift_proxy_config) do
|
||||
|
||||
ensurable
|
||||
|
||||
newparam(:name, :namevar => true) do
|
||||
desc 'Section/setting name to manage from /etc/swift/proxy-server.conf'
|
||||
newvalues(/\S+\/\S+/)
|
||||
end
|
||||
|
||||
newproperty(:value) do
|
||||
desc 'The value of the setting to be defined.'
|
||||
munge do |value|
|
||||
value = value.to_s.strip
|
||||
value.capitalize! if value =~ /^(true|false)$/i
|
||||
value
|
||||
end
|
||||
|
||||
def is_to_s( currentvalue )
|
||||
if resource.secret?
|
||||
return '[old secret redacted]'
|
||||
else
|
||||
return currentvalue
|
||||
end
|
||||
end
|
||||
|
||||
def should_to_s( newvalue )
|
||||
if resource.secret?
|
||||
return '[new secret redacted]'
|
||||
else
|
||||
return newvalue
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
newparam(:secret, :boolean => true) do
|
||||
desc 'Whether to hide the value from Puppet logs. Defaults to `false`.'
|
||||
newvalues(:true, :false)
|
||||
defaultto false
|
||||
end
|
||||
end
|
Loading…
x
Reference in New Issue
Block a user