]> gitweb.fluxo.info Git - puppet-stdlib.git/commitdiff
Add missing documentation for validate_augeas and validate_cmd to README.markdown
authorRaphaël Pinson <raphael.pinson@camptocamp.com>
Mon, 4 Mar 2013 22:37:57 +0000 (23:37 +0100)
committerRaphaël Pinson <raphael.pinson@camptocamp.com>
Mon, 4 Mar 2013 22:37:57 +0000 (23:37 +0100)
README.markdown

index c58d31ff5e633190a7f339316470719821f2dc64..f1ac6b3b97da4554818ca585452c75fb08b0745e 100644 (file)
@@ -777,6 +777,38 @@ The following values will fail, causing compilation to abort:
 
 
 
+- *Type*: statement
+
+validate_augeas
+--------------
+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
+abort with a parse error.
+
+A third argument can be specified, listing paths which should
+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:
+
+    validate_augeas($passwdcontent, 'Passwd.lns', ['$file/foo'])
+
+Or 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.
+
+A helpful error message can be returned like this:
+
+    validate_augeas($sudoerscontent, 'Sudoers.lns', [], 'Failed to validate sudoers content with Augeas')
+
+
 - *Type*: statement
 
 validate_bool
@@ -799,6 +831,29 @@ The following values will fail, causing compilation to abort:
 
 
 
+- *Type*: statement
+
+
+validate_cmd
+-------------
+Perform validation of a string with an external command.
+The first argument of this function should be a string to
+test, and the second argument should be a path to a test command
+taking a file as last argument. If the command, launched against
+a tempfile containing the passed string, returns a non-null value,
+compilation will abort with a parse error.
+
+If a third argument is specified, this will be the error message raised and
+seen by the user.
+
+A helpful error message can be returned like this:
+
+Example:
+
+    validate_cmd($sudoerscontent, '/usr/sbin/visudo -c -f', 'Visudo failed to validate sudoers content')
+
+
+
 - *Type*: statement
 
 validate_hash