diff options
Diffstat (limited to 'lib/puppet')
-rw-r--r-- | lib/puppet/parser/functions/ensure_packages.rb | 2 | ||||
-rw-r--r-- | lib/puppet/provider/file_line/ruby.rb | 2 | ||||
-rw-r--r-- | lib/puppet/type/file_line.rb | 21 |
3 files changed, 24 insertions, 1 deletions
diff --git a/lib/puppet/parser/functions/ensure_packages.rb b/lib/puppet/parser/functions/ensure_packages.rb index 504273d..17942b8 100644 --- a/lib/puppet/parser/functions/ensure_packages.rb +++ b/lib/puppet/parser/functions/ensure_packages.rb @@ -36,7 +36,9 @@ third argument to the ensure_resource() function. Puppet::Parser::Functions.function(:ensure_resource) packages.each { |package_name| + if !findresource("Package[#{package_name}]") function_ensure_resource(['package', package_name, defaults ]) + end } end end diff --git a/lib/puppet/provider/file_line/ruby.rb b/lib/puppet/provider/file_line/ruby.rb index beeb430..fbf7d8e 100644 --- a/lib/puppet/provider/file_line/ruby.rb +++ b/lib/puppet/provider/file_line/ruby.rb @@ -40,7 +40,7 @@ Puppet::Type.type(:file_line).provide(:ruby) do # file; for now assuming that this type is only used on # small-ish config files that can fit into memory without # too much trouble. - @lines ||= File.readlines(resource[:path]) + @lines ||= File.readlines(resource[:path], :encoding => resource[:encoding]) end def match_regex diff --git a/lib/puppet/type/file_line.rb b/lib/puppet/type/file_line.rb index 7b7d44e..e82b246 100644 --- a/lib/puppet/type/file_line.rb +++ b/lib/puppet/type/file_line.rb @@ -48,6 +48,22 @@ Puppet::Type.newtype(:file_line) do followed by HTTP_PROXY and delete it. If multiple lines match, an error will be raised unless the `multiple => true` parameter is set. + Encoding example: + + file_line { "XScreenSaver": + ensure => present, + path => '/root/XScreenSaver' + line => "*lock: 10:00:00", + match => '^*lock:', + encoding => "iso-8859-1", + } + + Files with special characters that are not valid UTF-8 will give the + error message "invalid byte sequence in UTF-8". In this case, determine + the correct file encoding and specify the correct encoding using the + encoding attribute, the value of which needs to be a valid Ruby character + encoding. + **Autorequires:** If Puppet is managing the file that will contain the line being managed, the file_line resource will autorequire that file. EOT @@ -107,6 +123,11 @@ Puppet::Type.newtype(:file_line) do defaultto true end + newparam(:encoding) do + desc 'For files that are not UTF-8 encoded, specify encoding such as iso-8859-1' + defaultto 'UTF-8' + end + # Autorequire the file resource if it's being managed autorequire(:file) do self[:path] |