summaryrefslogtreecommitdiff
path: root/manifests/lens.pp
diff options
context:
space:
mode:
Diffstat (limited to 'manifests/lens.pp')
-rw-r--r--manifests/lens.pp26
1 files changed, 18 insertions, 8 deletions
diff --git a/manifests/lens.pp b/manifests/lens.pp
index 7c55b7a..ac4fddf 100644
--- a/manifests/lens.pp
+++ b/manifests/lens.pp
@@ -1,15 +1,16 @@
-# == Definition: augeas::lens
+# Definition: augeas::lens
#
# Deploy an Augeas lens (and its test file).
# Check the lens (and run the unit tests) automatically and remove the files if
# the checks fail.
#
# Parameters:
-# - *ensure*: present/absent
-# - *lens_source*: the source for the lens
-# - *test_source*: optionally, the source for the test file.
-# - *stock_since*: optionally, indicate in which version of Augeas
-# the lens became stock, so it will not be deployed above that version.
+# ['ensure'] - present/absent
+# ['lens_source'] - the source for the lens
+# ['test_source'] - optionally, the source for the test file.
+# ['stock_since'] - optionally, indicate in which version of Augeas
+# the lens became stock, so it will not be deployed
+# above that version.
#
# Example usage:
#
@@ -18,15 +19,24 @@
# test_source => 'puppet:///modules/networkmanager/lenses/test_networkmanager.aug',
# stock_since => '1.0.0',
# }
+#
define augeas::lens (
$lens_source,
$ensure=present,
$test_source=false,
$stock_since=false,
) {
+ if !defined(Class['augeas']) {
+ fail('You must declare the augeas class before using augeas::lens')
+ }
+
+ if (!$stock_since or versioncmp($::augeasversion, $stock_since) < 0) {
- if (!$stock_since or !versioncmp($::augeasversion, $stock_since)) {
- include augeas
+ validate_re(
+ $augeas::lens_dir,
+ '/.*',
+ "'${augeas::lens_dir}' is not a valid path for lens ${name}"
+ )
$lens_dest = "${augeas::lens_dir}/${name}.aug"
$test_dest = "${augeas::lens_dir}/tests/test_${name}.aug"