summaryrefslogtreecommitdiff
path: root/puppet/modules/augeas/manifests
diff options
context:
space:
mode:
authorMicah Anderson <micah@riseup.net>2016-11-04 10:54:28 -0400
committerMicah Anderson <micah@riseup.net>2016-11-04 10:54:28 -0400
commit34a381efa8f6295080c843f86bfa07d4e41056af (patch)
tree9282cf5d4c876688602705a7fa0002bc4a810bde /puppet/modules/augeas/manifests
parent0a72bc6fd292bf9367b314fcb0347c4d35042f16 (diff)
parent5821964ff7e16ca7aa9141bd09a77d355db492a9 (diff)
Merge branch 'develop'
Diffstat (limited to 'puppet/modules/augeas/manifests')
m---------puppet/modules/augeas0
-rw-r--r--puppet/modules/augeas/manifests/files.pp36
-rw-r--r--puppet/modules/augeas/manifests/init.pp24
-rw-r--r--puppet/modules/augeas/manifests/lens.pp79
-rw-r--r--puppet/modules/augeas/manifests/packages.pp14
-rw-r--r--puppet/modules/augeas/manifests/params.pp37
6 files changed, 190 insertions, 0 deletions
diff --git a/puppet/modules/augeas b/puppet/modules/augeas
deleted file mode 160000
-Subproject 58ab2b90c52a5d951fa41596827bc3b6f52310e
diff --git a/puppet/modules/augeas/manifests/files.pp b/puppet/modules/augeas/manifests/files.pp
new file mode 100644
index 00000000..c73c19bb
--- /dev/null
+++ b/puppet/modules/augeas/manifests/files.pp
@@ -0,0 +1,36 @@
+# Class: augeas::files
+#
+# Sets up directories and files for Augeas
+#
+class augeas::files {
+ $lens_dir = $augeas::lens_dir
+
+ # ensure no file not managed by puppet ends up in there.
+ file { $lens_dir:
+ ensure => directory,
+ purge => $::augeas::purge,
+ force => true,
+ recurse => true,
+ recurselimit => 1,
+ mode => '0644',
+ owner => 'root',
+ group => 'root',
+ }
+
+ file { "${lens_dir}/dist":
+ ensure => directory,
+ purge => false,
+ mode => '0644',
+ owner => 'root',
+ group => 'root',
+ }
+
+ file { "${lens_dir}/tests":
+ ensure => directory,
+ purge => $::augeas::purge,
+ force => true,
+ mode => '0644',
+ owner => 'root',
+ group => 'root',
+ }
+}
diff --git a/puppet/modules/augeas/manifests/init.pp b/puppet/modules/augeas/manifests/init.pp
new file mode 100644
index 00000000..41f4f875
--- /dev/null
+++ b/puppet/modules/augeas/manifests/init.pp
@@ -0,0 +1,24 @@
+# Class: augeas
+#
+# Install and configure Augeas
+#
+# Parameters:
+# ['version'] - the desired version of 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_version = present,
+ $lens_dir = $augeas::params::lens_dir,
+ $purge = true,
+) inherits augeas::params {
+
+ class {'::augeas::packages': } ->
+ class {'::augeas::files': } ->
+ Class['augeas']
+
+ # lint:ignore:spaceship_operator_without_tag
+ Package['ruby-augeas', $augeas::params::augeas_pkgs] -> Augeas <| |>
+ # lint:endignore
+}
diff --git a/puppet/modules/augeas/manifests/lens.pp b/puppet/modules/augeas/manifests/lens.pp
new file mode 100644
index 00000000..b5b9acd6
--- /dev/null
+++ b/puppet/modules/augeas/manifests/lens.pp
@@ -0,0 +1,79 @@
+# 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.
+#
+# 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',
+# }
+#
+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')
+ }
+
+ File {
+ owner => 'root',
+ group => 'root',
+ mode => '0644',
+ }
+
+ Exec {
+ path => $::path,
+ }
+
+ if (!$stock_since or versioncmp($::augeasversion, $stock_since) < 0) {
+
+ 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"
+
+ file { $lens_dest:
+ ensure => $ensure,
+ source => $lens_source,
+ }
+
+ exec { "Typecheck lens ${name}":
+ command => "augparse -I ${augeas::lens_dir} ${lens_dest} || (rm -f ${lens_dest} && exit 1)",
+ refreshonly => true,
+ subscribe => File[$lens_dest],
+ }
+
+ if $test_source {
+ file { $test_dest:
+ ensure => $ensure,
+ source => $test_source,
+ notify => Exec["Test lens ${name}"],
+ }
+
+ exec { "Test lens ${name}":
+ command => "augparse -I ${augeas::lens_dir} ${test_dest} || (rm -f ${lens_dest} && rm -f ${test_dest} && exit 1)",
+ refreshonly => true,
+ subscribe => File[$lens_dest, $test_dest],
+ }
+ }
+ }
+}
diff --git a/puppet/modules/augeas/manifests/packages.pp b/puppet/modules/augeas/manifests/packages.pp
new file mode 100644
index 00000000..ff8628df
--- /dev/null
+++ b/puppet/modules/augeas/manifests/packages.pp
@@ -0,0 +1,14 @@
+# Class: augeas::packages
+#
+# Sets up packages for Augeas
+#
+class augeas::packages {
+ package { $::augeas::params::augeas_pkgs:
+ ensure => $::augeas::version,
+ }
+
+ package { 'ruby-augeas':
+ ensure => $::augeas::ruby_version,
+ name => $::augeas::params::ruby_pkg,
+ }
+}
diff --git a/puppet/modules/augeas/manifests/params.pp b/puppet/modules/augeas/manifests/params.pp
new file mode 100644
index 00000000..e5400339
--- /dev/null
+++ b/puppet/modules/augeas/manifests/params.pp
@@ -0,0 +1,37 @@
+# Class: augeas::params
+#
+# Default parameters for the Augeas module
+#
+class augeas::params {
+ $lens_dir = '/usr/share/augeas/lenses'
+
+ case $::osfamily {
+ 'RedHat': {
+ $ruby_pkg = '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 {
+ $ruby_pkg = 'ruby2.1-rubygem-ruby-augeas'
+ }
+ $augeas_pkgs = ['augeas', 'augeas-lenses', 'libaugeas0' ]
+ }
+
+ 'Debian': {
+ if versioncmp($::rubyversion, '1.9.1') >= 0 {
+ $ruby_pkg = 'libaugeas-ruby1.9.1'
+ } else {
+ $ruby_pkg = 'libaugeas-ruby1.8'
+ }
+ $augeas_pkgs = ['augeas-lenses', 'libaugeas0', 'augeas-tools']
+ }
+
+ default: { fail("Unsupported OS family: ${::osfamily}") }
+ }
+}