Allow values with spaces to be parsed and set

Previously, the following stanza would fail as a result of the
ini_setting type not being able to parse spaces in setting values.

  ini_setting { 'main_config_version':
    ensure  => present,
    path    => '/etc/puppetlabs/puppet/puppet.conf',
    section => 'main',
    setting => 'config_version',
    value   => '/etc/puppetlabs/puppet/config_version.sh $environment',
  }

This commit modifes the SETTING_REGEX to account for spaces in setting values.
This commit is contained in:
Reid Vandewiele 2012-09-29 12:39:00 -07:00
parent e81a69adb5
commit 3829e20c49
2 changed files with 4 additions and 2 deletions

View file

@ -6,7 +6,7 @@ module Util
class IniFile
SECTION_REGEX = /^\s*\[([\w\d\.\\\/\-\:]+)\]\s*$/
SETTING_REGEX = /^\s*([\w\d\.\\\/\-]+)\s*=\s*([\S]+)\s*$/
SETTING_REGEX = /^\s*([\w\d\.\\\/\-]+)\s*=\s*([\S\s]*\S)\s*$/
def initialize(path, key_val_separator = ' = ')
@path = path

View file

@ -26,6 +26,7 @@ foo= foovalue2
baz=bazvalue
#another comment
; yet another comment
zot = multi word value
EOS
template.split("\n")
}
@ -45,6 +46,7 @@ baz=bazvalue
subject.get_value("section1", "bar").should == "barvalue"
subject.get_value("section2", "foo").should == "foovalue2"
subject.get_value("section2", "baz").should == "bazvalue"
subject.get_value("section2", "zot").should == "multi word value"
end
end
@ -102,4 +104,4 @@ foo=foovalue
end
end
end
end