summaryrefslogtreecommitdiff
path: root/lib/puppet/type/ini_subsetting.rb
diff options
context:
space:
mode:
authorKarel Brezina <karel.brezina@gmail.com>2013-02-15 10:56:44 +0100
committerKarel Brezina <karel.brezina@gmail.com>2013-03-25 11:34:37 +0100
commit4351d8b9c8dac40f0f733fd7622d655241f113ba (patch)
tree50020a3b7d7abd357feb7a7eb70666144f3dafd3 /lib/puppet/type/ini_subsetting.rb
parent2008179ebea70d296f65a1809c961951884a7b11 (diff)
downloadpuppet-inifile-4351d8b9c8dac40f0f733fd7622d655241f113ba.tar.gz
puppet-inifile-4351d8b9c8dac40f0f733fd7622d655241f113ba.tar.bz2
Added 'ini_subsetting' custom resource type
Diffstat (limited to 'lib/puppet/type/ini_subsetting.rb')
-rw-r--r--lib/puppet/type/ini_subsetting.rb55
1 files changed, 55 insertions, 0 deletions
diff --git a/lib/puppet/type/ini_subsetting.rb b/lib/puppet/type/ini_subsetting.rb
new file mode 100644
index 0000000..dd146c2
--- /dev/null
+++ b/lib/puppet/type/ini_subsetting.rb
@@ -0,0 +1,55 @@
+Puppet::Type.newtype(:ini_subsetting) do
+
+ ensurable do
+ defaultvalues
+ defaultto :present
+ end
+
+ newparam(:name, :namevar => true) do
+ desc 'An arbitrary name used as the identity of the resource.'
+ end
+
+ newparam(:section) do
+ desc 'The name of the section in the ini file in which the setting should be defined.'
+ end
+
+ newparam(:setting) do
+ desc 'The name of the setting to be defined.'
+ end
+
+ newparam(:subsetting) do
+ desc 'The name of the subsetting to be defined.'
+ end
+
+ newparam(:subsetting_separator) do
+ desc 'The separator string between subsettings. Defaults to " "'
+ defaultto(" ")
+ end
+
+ newparam(:path) do
+ desc 'The ini file Puppet will ensure contains the specified setting.'
+ validate do |value|
+ unless (Puppet.features.posix? and value =~ /^\//) or (Puppet.features.microsoft_windows? and (value =~ /^.:\// or value =~ /^\/\/[^\/]+\/[^\/]+/))
+ raise(Puppet::Error, "File paths must be fully qualified, not '#{value}'")
+ end
+ end
+ end
+
+ newparam(:key_val_separator) do
+ desc 'The separator string to use between each setting name and value. ' +
+ 'Defaults to " = ", but you could use this to override e.g. whether ' +
+ 'or not the separator should include whitespace.'
+ defaultto(" = ")
+
+ validate do |value|
+ unless value.scan('=').size == 1
+ raise Puppet::Error, ":key_val_separator must contain exactly one = character."
+ end
+ end
+ end
+
+ newproperty(:value) do
+ desc 'The value of the subsetting to be defined.'
+ end
+
+end