Add validate_augeas command#114
Add validate_augeas command#114jeffmccune merged 5 commits intopuppetlabs:masterfrom raphink:validate_augeas
Conversation
There was a problem hiding this comment.
Watch out for whitespace errors. I found this with git diff --check master.
There was a problem hiding this comment.
(I'll fix it up in my own topic branch, no action required.)
|
@raphink Does this function require augeaus? If so, I'd like to discuss the pros and cons of merging it into stdlib rather than another module. As it currently stands, stdlib does not have any dependencies other than Ruby and Puppet AFAIK, so this would be a big change from a dependency and requirements stand point. |
|
The function does require augeas indeed. That said, it will not make stdlib depend on augeas per se. Rather, you will need |
|
@raphink Yes, if the function disabled itself if Augeas isn't present then I think it would be OK to include. It may also be worth checking how the Augeas types and providers perform this check. If it's a public API then this parser function could re-use the behavior. |
|
@jeffmccune I added changes to:
|
There was a problem hiding this comment.
This is good, but I think it would be great if the error message helped the end user with next steps to make this work. For example, perhaps a URL to a document that describes how to enable the augeas feature in Puppet.
Hopefully we have this documented at http://docs.puppetlabs.com/
Maybe something like, "requires the ruby augeas bindings. Information about how to satisfy this requirements is available at: http://..."
I think this would be great because a ParseError aborts catalog compilation entirely, so the user is sort of "stuck" if they encounter this error.
|
I think this is ready to go once the one comment about "next steps" when the augeas feature is not available is addressed and the tests are passing. -Jeff |
There was a problem hiding this comment.
@jeffmccune This URL is where augeas installation for puppet is documented.
|
Merged into master as 4d24bd3. This should be released in 3.3.0. Thanks again for the contribution! -Jeff |
This PR adds a new
validate_augeasfunction, which takes a string and an Augeas lens, and validates the string against the Augeas lens. Example:The function optionally takes an array of paths which should not be found in the content.
For example, if you want to make sure your passwd content never contains a user
foo, you could write:Or if you wanted to ensure that no users used the '/bin/barsh' shell, you could use:
Like all validate_* functions, it fails compilation if the check fails. It also takes an optional 4rd argument to specify a nicer message.