]> git.donarmstrong.com Git - dsa-puppet.git/blob - 3rdparty/modules/inifile/lib/puppet/type/ini_setting.rb
add puppetlabs/inifile to 3rdparty
[dsa-puppet.git] / 3rdparty / modules / inifile / lib / puppet / type / ini_setting.rb
1 Puppet::Type.newtype(:ini_setting) do
2
3   ensurable do
4     defaultvalues
5     defaultto :present
6   end
7
8   newparam(:name, :namevar => true) do
9     desc 'An arbitrary name used as the identity of the resource.'
10   end
11
12   newparam(:section) do
13     desc 'The name of the section in the ini file in which the setting should be defined.' +
14       'If not provided, defaults to global, top of file, sections.'
15     defaultto("")
16   end
17
18   newparam(:setting) do
19     desc 'The name of the setting to be defined.'
20   end
21
22   newparam(:path) do
23     desc 'The ini file Puppet will ensure contains the specified setting.'
24     validate do |value|
25       unless (Puppet.features.posix? and value =~ /^\//) or (Puppet.features.microsoft_windows? and (value =~ /^.:\// or value =~ /^\/\/[^\/]+\/[^\/]+/))
26         raise(Puppet::Error, "File paths must be fully qualified, not '#{value}'")
27       end
28     end
29   end
30
31   newparam(:key_val_separator) do
32     desc 'The separator string to use between each setting name and value. ' +
33         'Defaults to " = ", but you could use this to override e.g. ": ", or' +
34         'whether or not the separator should include whitespace.'
35     defaultto(" = ")
36   end
37
38   newproperty(:value) do
39     desc 'The value of the setting to be defined.'
40   end
41
42   newparam(:section_prefix) do
43     desc 'The prefix to the section name\'s header.' +
44         'Defaults to \'[\'.'
45     defaultto('[')
46   end
47
48   newparam(:section_suffix) do
49     desc 'The suffix to the section name\'s header.' +
50         'Defaults to \']\'.'
51     defaultto(']')
52   end
53
54 end