summaryrefslogtreecommitdiff
path: root/lib/puppet
diff options
context:
space:
mode:
Diffstat (limited to 'lib/puppet')
-rw-r--r--lib/puppet/provider/ini_setting/ruby.rb3
-rw-r--r--lib/puppet/type/ini_setting.rb9
-rw-r--r--lib/puppet/util/ini_file.rb7
3 files changed, 14 insertions, 5 deletions
diff --git a/lib/puppet/provider/ini_setting/ruby.rb b/lib/puppet/provider/ini_setting/ruby.rb
index 9f13dff..ba8165c 100644
--- a/lib/puppet/provider/ini_setting/ruby.rb
+++ b/lib/puppet/provider/ini_setting/ruby.rb
@@ -14,6 +14,7 @@ Puppet::Type.type(:ini_setting).provide(:ruby) do
private
def ini_file
- @ini_file ||= Puppet::Util::IniFile.new(resource[:path])
+ @ini_file ||= Puppet::Util::IniFile.new(resource[:path],
+ resource[:key_val_separator])
end
end
diff --git a/lib/puppet/type/ini_setting.rb b/lib/puppet/type/ini_setting.rb
index 9af47c1..f1ab490 100644
--- a/lib/puppet/type/ini_setting.rb
+++ b/lib/puppet/type/ini_setting.rb
@@ -30,4 +30,11 @@ Puppet::Type.newtype(:ini_setting) do
end
end
-end \ No newline at end of file
+ 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(" = ")
+ end
+
+end
diff --git a/lib/puppet/util/ini_file.rb b/lib/puppet/util/ini_file.rb
index 4fe4169..36bc8a6 100644
--- a/lib/puppet/util/ini_file.rb
+++ b/lib/puppet/util/ini_file.rb
@@ -8,8 +8,9 @@ module Util
SECTION_REGEX = /^\s*\[([\w\d\.\\\/\-\:]+)\]\s*$/
SETTING_REGEX = /^\s*([\w\d\.\\\/\-]+)\s*=\s*([\S]+)\s*$/
- def initialize(path)
+ def initialize(path, key_val_separator = ' = ')
@path = path
+ @key_val_separator = key_val_separator
@section_names = []
@sections_hash = {}
if File.file?(@path)
@@ -56,7 +57,7 @@ module Util
end
section.additional_settings.each_pair do |key, value|
- fh.puts("#{key} = #{value}")
+ fh.puts("#{key}#{@key_val_separator}#{value}")
end
end
end
@@ -106,7 +107,7 @@ module Util
(section.start_line..section.end_line).each do |line_num|
if (match = SETTING_REGEX.match(lines[line_num]))
if (match[1] == setting)
- lines[line_num] = "#{setting} = #{value}"
+ lines[line_num] = "#{setting}#{@key_val_separator}#{value}"
end
end
end