X-Git-Url: https://git.adam-barratt.org.uk/?p=mirror%2Fdsa-puppet.git;a=blobdiff_plain;f=3rdparty%2Fmodules%2Fstdlib%2Flib%2Fpuppet%2Fparser%2Ffunctions%2Fvalidate_augeas.rb;h=26e51e8ffab0f92d79513cbdcc72fe507bfb4315;hp=97f3127e3f7b30b9ba77255eb774bf1791d8ec69;hb=30caaa85aed7015ca0d77216bff175eebd917eb7;hpb=6f656bd4265e3dab13b9af2bf96e9044322e9d8f diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/validate_augeas.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/validate_augeas.rb index 97f3127e3..26e51e8ff 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/validate_augeas.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/validate_augeas.rb @@ -4,8 +4,10 @@ require 'tempfile' # validate_augaes.rb # module Puppet::Parser::Functions - newfunction(:validate_augeas, :doc => <<-'DOC') do |args| - Perform validation of a string using an Augeas lens + newfunction(:validate_augeas, :doc => <<-DOC + @summary + Perform validation of a string using an Augeas lens + The first argument of this function should be a string to test, and the second argument should be the name of the Augeas lens to use. If Augeas fails to parse the string with the lens, the compilation will @@ -15,24 +17,30 @@ module Puppet::Parser::Functions not be found in the file. The `$file` variable points to the location of the temporary file being tested in the Augeas tree. - For example, if you want to make sure your passwd content never contains - a user `foo`, you could write: + @return + validate string using an Augeas lens + + @example **Usage** + + If you want to make sure your passwd content never contains + a user `foo`, you could write: validate_augeas($passwdcontent, 'Passwd.lns', ['$file/foo']) - Or if you wanted to ensure that no users used the '/bin/barsh' shell, - you could use: + If you wanted to ensure that no users used the '/bin/barsh' shell, + you could use: validate_augeas($passwdcontent, 'Passwd.lns', ['$file/*[shell="/bin/barsh"]'] - If a fourth argument is specified, this will be the error message raised and - seen by the user. + If a fourth argument is specified, this will be the error message raised and + seen by the user. - A helpful error message can be returned like this: + A helpful error message can be returned like this: validate_augeas($sudoerscontent, 'Sudoers.lns', [], 'Failed to validate sudoers content with Augeas') DOC + ) do |args| unless Puppet.features.augeas? raise Puppet::ParseError, 'validate_augeas(): this function requires the augeas feature. See http://docs.puppetlabs.com/guides/augeas.html#pre-requisites for how to activate it.' end