summaryrefslogtreecommitdiff
path: root/manifests
diff options
context:
space:
mode:
Diffstat (limited to 'manifests')
-rw-r--r--manifests/init.pp24
-rw-r--r--manifests/lens.pp64
-rw-r--r--manifests/packages.pp2
-rw-r--r--manifests/params.pp34
4 files changed, 88 insertions, 36 deletions
diff --git a/manifests/init.pp b/manifests/init.pp
index 41f4f87..94e50b9 100644
--- a/manifests/init.pp
+++ b/manifests/init.pp
@@ -4,21 +4,31 @@
#
# Parameters:
# ['version'] - the desired version of Augeas
+# ['ruby_package'] - the desired package name of the Ruby bindings for Augeas
# ['ruby_version'] - the desired version of the Ruby bindings for Augeas
# ['lens_dir'] - the lens directory to use
# ['purge'] - whether to purge lens directories
class augeas (
$version = present,
+ $ruby_package = $::augeas::params::ruby_pkg,
$ruby_version = present,
- $lens_dir = $augeas::params::lens_dir,
+ $lens_dir = $::augeas::params::lens_dir,
$purge = true,
) inherits augeas::params {
- class {'::augeas::packages': } ->
- class {'::augeas::files': } ->
- Class['augeas']
+ if versioncmp($::puppetversion, '4.0.0') >= 0 {
+ anchor { 'augeas::begin': }
+ -> class {'::augeas::files': }
+ -> anchor { 'augeas::end': }
+ } else {
+ anchor { 'augeas::begin': }
+ -> class {'::augeas::packages': }
+ -> class {'::augeas::files': }
+ -> anchor { 'augeas::end': }
+
+ # lint:ignore:spaceship_operator_without_tag
+ Package['ruby-augeas', $augeas::params::augeas_pkgs] -> Augeas <| |>
+ # lint:endignore
+ }
- # lint:ignore:spaceship_operator_without_tag
- Package['ruby-augeas', $augeas::params::augeas_pkgs] -> Augeas <| |>
- # lint:endignore
}
diff --git a/manifests/lens.pp b/manifests/lens.pp
index b5b9acd..bda7a0c 100644
--- a/manifests/lens.pp
+++ b/manifests/lens.pp
@@ -6,7 +6,9 @@
#
# Parameters:
# ['ensure'] - present/absent
+# ['lens_content'] - the content of the lens
# ['lens_source'] - the source for the lens
+# ['test_content'] - optionally, the content of the test
# ['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
@@ -15,19 +17,39 @@
# Example usage:
#
# augeas::lens { 'networkmanager':
-# lens_source => 'puppet:///modules/networkmanager/lenses/networkmanager.aug',
-# test_source => 'puppet:///modules/networkmanager/lenses/test_networkmanager.aug',
-# stock_since => '1.0.0',
+# lens_content => file('networkmanager/lenses/networkmanager.aug'),
+# test_content => file('networkmanager/lenses/test_networkmanager.aug'),
+# stock_since => '1.0.0',
# }
#
define augeas::lens (
- $lens_source,
- $ensure=present,
- $test_source=false,
- $stock_since=false,
+ $ensure = present,
+ $lens_content = undef,
+ $lens_source = undef,
+ $test_content = undef,
+ $test_source = undef,
+ $stock_since = false,
) {
- if !defined(Class['augeas']) {
- fail('You must declare the augeas class before using augeas::lens')
+ include ::augeas
+
+ if $lens_source != undef {
+ if $lens_content != undef {
+ fail "You can't set both \$lens_source and \$lens_content"
+ } else {
+ warning 'Passing "lens_source" is deprecated; please use "lens_content"'
+ }
+ } else {
+ if $lens_content == undef {
+ fail "You must set either \$lens_source or \$lens_content"
+ }
+ }
+
+ if $test_source != undef {
+ if $test_content != undef {
+ fail "You can't set both \$test_source and \$test_content"
+ } else {
+ warning 'Passing "test_source" is deprecated; please use "test_content"'
+ }
}
File {
@@ -36,10 +58,6 @@ define augeas::lens (
mode => '0644',
}
- Exec {
- path => $::path,
- }
-
if (!$stock_since or versioncmp($::augeasversion, $stock_since) < 0) {
validate_re(
@@ -51,26 +69,34 @@ define augeas::lens (
$lens_dest = "${augeas::lens_dir}/${name}.aug"
$test_dest = "${augeas::lens_dir}/tests/test_${name}.aug"
+ # lint:ignore:source_without_rights
file { $lens_dest:
- ensure => $ensure,
- source => $lens_source,
+ ensure => $ensure,
+ source => $lens_source,
+ content => $lens_content,
}
+ # lint:endignore
exec { "Typecheck lens ${name}":
command => "augparse -I ${augeas::lens_dir} ${lens_dest} || (rm -f ${lens_dest} && exit 1)",
+ path => "/opt/puppetlabs/puppet/bin:${::path}",
refreshonly => true,
subscribe => File[$lens_dest],
}
- if $test_source {
+ if $test_source or $test_content {
+ # lint:ignore:source_without_rights
file { $test_dest:
- ensure => $ensure,
- source => $test_source,
- notify => Exec["Test lens ${name}"],
+ ensure => $ensure,
+ source => $test_source,
+ content => $test_content,
+ notify => Exec["Test lens ${name}"],
}
+ # lint:endignore
exec { "Test lens ${name}":
command => "augparse -I ${augeas::lens_dir} ${test_dest} || (rm -f ${lens_dest} && rm -f ${test_dest} && exit 1)",
+ path => "/opt/puppetlabs/puppet/bin:${::path}",
refreshonly => true,
subscribe => File[$lens_dest, $test_dest],
}
diff --git a/manifests/packages.pp b/manifests/packages.pp
index ff8628d..ff0d5c8 100644
--- a/manifests/packages.pp
+++ b/manifests/packages.pp
@@ -9,6 +9,6 @@ class augeas::packages {
package { 'ruby-augeas':
ensure => $::augeas::ruby_version,
- name => $::augeas::params::ruby_pkg,
+ name => $::augeas::ruby_package,
}
}
diff --git a/manifests/params.pp b/manifests/params.pp
index e540033..bf28630 100644
--- a/manifests/params.pp
+++ b/manifests/params.pp
@@ -3,28 +3,34 @@
# Default parameters for the Augeas module
#
class augeas::params {
- $lens_dir = '/usr/share/augeas/lenses'
case $::osfamily {
'RedHat': {
- $ruby_pkg = 'ruby-augeas'
+ $ruby_pkg = $::operatingsystem ? {
+ # Amazon Linux AMI (2014.09 and 2015.03) uses ruby 2.0
+ 'Amazon' => 'ruby20-augeas',
+ default => 'ruby-augeas'
+ }
$augeas_pkgs = ['augeas', 'augeas-libs']
}
'Suse': {
- # RPM Sources: https://build.opensuse.org/project/show/systemsmanagement:puppet
- # SLES 11 SP3
- if versioncmp($::rubyversion, '1.8.7') >= 0 {
- $ruby_pkg = 'ruby1.8-rubygem-ruby-augeas'
- # SLES 12
- } else {
+ # RPM Sources: https://build.opensuse.org/project/show/systemsmanagement:puppet
+ if versioncmp($::rubyversion, '2.1.2') >= 0 {
+ # SLES 12 / openSUSE
$ruby_pkg = 'ruby2.1-rubygem-ruby-augeas'
+ } else {
+ # SLES 11 SP3
+ $ruby_pkg = 'ruby1.8-rubygem-ruby-augeas'
}
$augeas_pkgs = ['augeas', 'augeas-lenses', 'libaugeas0' ]
}
'Debian': {
- if versioncmp($::rubyversion, '1.9.1') >= 0 {
+ if versioncmp($::rubyversion, '2.1.0') >= 0 {
+ $ruby_pkg = 'ruby-augeas'
+ }
+ elsif versioncmp($::rubyversion, '1.9.1') >= 0 {
$ruby_pkg = 'libaugeas-ruby1.9.1'
} else {
$ruby_pkg = 'libaugeas-ruby1.8'
@@ -34,4 +40,14 @@ class augeas::params {
default: { fail("Unsupported OS family: ${::osfamily}") }
}
+
+ if versioncmp($::puppetversion, '4.0.0') >= 0 {
+ $lens_dir = '/opt/puppetlabs/puppet/share/augeas/lenses'
+ } elsif (defined('$is_pe') and str2bool("${::is_pe}")) { # lint:ignore:only_variable_string
+ # puppet enterpise has a different lens location
+ $lens_dir = '/opt/puppet/share/augeas/lenses'
+ } else {
+ $lens_dir = '/usr/share/augeas/lenses'
+ }
+
}