From 82e4a62312a9ba8b0aaaebada7b600b70159abb7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Pinson?= Date: Wed, 12 Mar 2014 13:14:04 +0100 Subject: [PATCH 01/29] Cleanup, remove providers from core tree --- .fixtures.yml | 5 +- lib/augeasproviders.rb | 2 - lib/augeasproviders/mounttab.rb | 4 - lib/augeasproviders/mounttab/fstab.rb | 125 ---- lib/augeasproviders/mounttab/vfstab.rb | 119 ---- lib/augeasproviders/type.rb | 46 -- .../provider/apache_directive/augeas.rb | 99 --- lib/puppet/provider/apache_setenv/augeas.rb | 68 -- lib/puppet/provider/host/augeas.rb | 167 ----- lib/puppet/provider/kernel_parameter/grub.rb | 125 ---- lib/puppet/provider/kernel_parameter/grub2.rb | 119 ---- lib/puppet/provider/mailalias/augeas.rb | 113 ---- lib/puppet/provider/mounttab/augeas.rb | 171 ----- lib/puppet/provider/nrpe_command/augeas.rb | 41 -- lib/puppet/provider/pam/augeas.rb | 125 ---- lib/puppet/provider/pg_hba/augeas.rb | 104 ---- lib/puppet/provider/puppet_auth/augeas.rb | 119 ---- lib/puppet/provider/shellvar/augeas.rb | 252 -------- lib/puppet/provider/sshd_config/augeas.rb | 205 ------ .../provider/sshd_config_subsystem/augeas.rb | 55 -- lib/puppet/provider/sysctl/augeas.rb | 122 ---- lib/puppet/provider/syslog/augeas.rb | 107 ---- lib/puppet/provider/syslog/rsyslog.rb | 17 - lib/puppet/type/apache_directive.rb | 41 -- lib/puppet/type/apache_setenv.rb | 32 - lib/puppet/type/kernel_parameter.rb | 35 -- lib/puppet/type/nrpe_command.rb | 28 - lib/puppet/type/pam.rb | 99 --- lib/puppet/type/pg_hba.rb | 137 ---- lib/puppet/type/puppet_auth.rb | 105 ---- lib/puppet/type/shellvar.rb | 178 ------ lib/puppet/type/sshd_config.rb | 64 -- lib/puppet/type/sshd_config_subsystem.rb | 28 - lib/puppet/type/sysctl.rb | 73 --- lib/puppet/type/syslog.rb | 66 -- manifests/init.pp | 17 - .../provider/apache_directive/augeas/broken | 1 - .../provider/apache_directive/augeas/empty | 0 .../provider/apache_directive/augeas/full | 241 -------- .../provider/apache_directive/augeas/simple | 4 - .../provider/apache_setenv/augeas/broken | 1 - .../provider/apache_setenv/augeas/empty | 0 .../puppet/provider/apache_setenv/augeas/full | 241 -------- .../provider/apache_setenv/augeas/simple | 4 - .../unit/puppet/provider/host/augeas/broken | 1 - .../unit/puppet/provider/host/augeas/empty | 1 - .../unit/puppet/provider/host/augeas/full | 4 - .../provider/kernel_parameter/grub/broken | 26 - .../provider/kernel_parameter/grub/full | 25 - .../provider/kernel_parameter/grub2/broken | 9 - .../provider/kernel_parameter/grub2/full | 9 - .../puppet/provider/mailalias/augeas/broken | 1 - .../puppet/provider/mailalias/augeas/empty | 0 .../puppet/provider/mailalias/augeas/full | 4 - .../provider/mailalias/augeas/fullquotes | 5 - .../puppet/provider/mounttab/fstab/broken | 17 - .../unit/puppet/provider/mounttab/fstab/empty | 0 .../unit/puppet/provider/mounttab/fstab/full | 16 - .../puppet/provider/mounttab/fstab/nooptions | 17 - .../puppet/provider/mounttab/vfstab/broken | 9 - .../puppet/provider/mounttab/vfstab/empty | 0 .../unit/puppet/provider/mounttab/vfstab/full | 9 - .../provider/nrpe_command/augeas/broken | 1 - .../puppet/provider/nrpe_command/augeas/empty | 0 .../puppet/provider/nrpe_command/augeas/full | 226 ------- .../unit/puppet/provider/pam/augeas/broken | 27 - .../unit/puppet/provider/pam/augeas/empty | 0 .../unit/puppet/provider/pam/augeas/full | 27 - .../unit/puppet/provider/pg_hba/augeas/broken | 82 --- .../unit/puppet/provider/pg_hba/augeas/empty | 1 - .../unit/puppet/provider/pg_hba/augeas/full | 82 --- .../puppet/provider/puppet_auth/augeas/broken | 1 - .../puppet/provider/puppet_auth/augeas/empty | 0 .../puppet/provider/puppet_auth/augeas/full | 53 -- .../puppet/provider/shellvar/augeas/broken | 8 - .../puppet/provider/shellvar/augeas/empty | 0 .../unit/puppet/provider/shellvar/augeas/full | 18 - .../puppet/provider/sshd_config/augeas/broken | 138 ----- .../puppet/provider/sshd_config/augeas/empty | 0 .../puppet/provider/sshd_config/augeas/full | 141 ----- .../provider/sshd_config/augeas/nomatch | 131 ---- .../sshd_config_subsystem/augeas/broken | 138 ----- .../sshd_config_subsystem/augeas/empty | 0 .../sshd_config_subsystem/augeas/full | 141 ----- .../unit/puppet/provider/sysctl/augeas/broken | 26 - .../unit/puppet/provider/sysctl/augeas/empty | 0 .../unit/puppet/provider/sysctl/augeas/full | 26 - .../unit/puppet/provider/sysctl/augeas/small | 8 - .../unit/puppet/provider/syslog/augeas/broken | 25 - .../unit/puppet/provider/syslog/augeas/empty | 0 .../unit/puppet/provider/syslog/augeas/full | 23 - .../puppet/provider/syslog/rsyslog/broken | 82 --- .../unit/puppet/provider/syslog/rsyslog/empty | 0 .../unit/puppet/provider/syslog/rsyslog/full | 80 --- spec/spec_helper.rb | 21 - .../provider/apache_directive/augeas_spec.rb | 192 ------ .../provider/apache_setenv/augeas_spec.rb | 153 ----- spec/unit/puppet/provider/host/augeas_spec.rb | 274 -------- .../provider/kernel_parameter/grub2_spec.rb | 324 ---------- .../provider/kernel_parameter/grub_spec.rb | 280 --------- .../puppet/provider/mailalias/augeas_spec.rb | 174 ------ .../puppet/provider/mounttab/fstab_spec.rb | 406 ------------ .../puppet/provider/mounttab/vfstab_spec.rb | 377 ----------- .../provider/nrpe_command/augeas_spec.rb | 113 ---- spec/unit/puppet/provider/pam/augeas_spec.rb | 190 ------ .../puppet/provider/pg_hba/augeas_spec.rb | 524 ---------------- .../provider/puppet_auth/augeas_spec.rb | 178 ------ .../puppet/provider/shellvar/augeas_spec.rb | 585 ------------------ .../provider/sshd_config/augeas_spec.rb | 522 ---------------- .../sshd_config_subsystem/augeas_spec.rb | 118 ---- .../puppet/provider/sysctl/augeas_spec.rb | 405 ------------ .../puppet/provider/syslog/augeas_spec.rb | 164 ----- .../puppet/provider/syslog/rsyslog_spec.rb | 168 ----- spec/unit/puppet/type/shellvar_type_spec.rb | 22 - 114 files changed, 1 insertion(+), 10532 deletions(-) delete mode 100644 lib/augeasproviders.rb delete mode 100644 lib/augeasproviders/mounttab.rb delete mode 100644 lib/augeasproviders/mounttab/fstab.rb delete mode 100644 lib/augeasproviders/mounttab/vfstab.rb delete mode 100644 lib/augeasproviders/type.rb delete mode 100644 lib/puppet/provider/apache_directive/augeas.rb delete mode 100644 lib/puppet/provider/apache_setenv/augeas.rb delete mode 100644 lib/puppet/provider/host/augeas.rb delete mode 100644 lib/puppet/provider/kernel_parameter/grub.rb delete mode 100644 lib/puppet/provider/kernel_parameter/grub2.rb delete mode 100644 lib/puppet/provider/mailalias/augeas.rb delete mode 100644 lib/puppet/provider/mounttab/augeas.rb delete mode 100644 lib/puppet/provider/nrpe_command/augeas.rb delete mode 100644 lib/puppet/provider/pam/augeas.rb delete mode 100644 lib/puppet/provider/pg_hba/augeas.rb delete mode 100644 lib/puppet/provider/puppet_auth/augeas.rb delete mode 100644 lib/puppet/provider/shellvar/augeas.rb delete mode 100644 lib/puppet/provider/sshd_config/augeas.rb delete mode 100644 lib/puppet/provider/sshd_config_subsystem/augeas.rb delete mode 100644 lib/puppet/provider/sysctl/augeas.rb delete mode 100644 lib/puppet/provider/syslog/augeas.rb delete mode 100644 lib/puppet/provider/syslog/rsyslog.rb delete mode 100644 lib/puppet/type/apache_directive.rb delete mode 100644 lib/puppet/type/apache_setenv.rb delete mode 100644 lib/puppet/type/kernel_parameter.rb delete mode 100644 lib/puppet/type/nrpe_command.rb delete mode 100644 lib/puppet/type/pam.rb delete mode 100644 lib/puppet/type/pg_hba.rb delete mode 100644 lib/puppet/type/puppet_auth.rb delete mode 100644 lib/puppet/type/shellvar.rb delete mode 100644 lib/puppet/type/sshd_config.rb delete mode 100644 lib/puppet/type/sshd_config_subsystem.rb delete mode 100644 lib/puppet/type/sysctl.rb delete mode 100644 lib/puppet/type/syslog.rb delete mode 100644 manifests/init.pp delete mode 100644 spec/fixtures/unit/puppet/provider/apache_directive/augeas/broken delete mode 100644 spec/fixtures/unit/puppet/provider/apache_directive/augeas/empty delete mode 100644 spec/fixtures/unit/puppet/provider/apache_directive/augeas/full delete mode 100644 spec/fixtures/unit/puppet/provider/apache_directive/augeas/simple delete mode 100644 spec/fixtures/unit/puppet/provider/apache_setenv/augeas/broken delete mode 100644 spec/fixtures/unit/puppet/provider/apache_setenv/augeas/empty delete mode 100644 spec/fixtures/unit/puppet/provider/apache_setenv/augeas/full delete mode 100644 spec/fixtures/unit/puppet/provider/apache_setenv/augeas/simple delete mode 100644 spec/fixtures/unit/puppet/provider/host/augeas/broken delete mode 100644 spec/fixtures/unit/puppet/provider/host/augeas/empty delete mode 100644 spec/fixtures/unit/puppet/provider/host/augeas/full delete mode 100644 spec/fixtures/unit/puppet/provider/kernel_parameter/grub/broken delete mode 100644 spec/fixtures/unit/puppet/provider/kernel_parameter/grub/full delete mode 100644 spec/fixtures/unit/puppet/provider/kernel_parameter/grub2/broken delete mode 100644 spec/fixtures/unit/puppet/provider/kernel_parameter/grub2/full delete mode 100644 spec/fixtures/unit/puppet/provider/mailalias/augeas/broken delete mode 100644 spec/fixtures/unit/puppet/provider/mailalias/augeas/empty delete mode 100644 spec/fixtures/unit/puppet/provider/mailalias/augeas/full delete mode 100644 spec/fixtures/unit/puppet/provider/mailalias/augeas/fullquotes delete mode 100644 spec/fixtures/unit/puppet/provider/mounttab/fstab/broken delete mode 100644 spec/fixtures/unit/puppet/provider/mounttab/fstab/empty delete mode 100644 spec/fixtures/unit/puppet/provider/mounttab/fstab/full delete mode 100644 spec/fixtures/unit/puppet/provider/mounttab/fstab/nooptions delete mode 100644 spec/fixtures/unit/puppet/provider/mounttab/vfstab/broken delete mode 100644 spec/fixtures/unit/puppet/provider/mounttab/vfstab/empty delete mode 100644 spec/fixtures/unit/puppet/provider/mounttab/vfstab/full delete mode 100644 spec/fixtures/unit/puppet/provider/nrpe_command/augeas/broken delete mode 100644 spec/fixtures/unit/puppet/provider/nrpe_command/augeas/empty delete mode 100644 spec/fixtures/unit/puppet/provider/nrpe_command/augeas/full delete mode 100644 spec/fixtures/unit/puppet/provider/pam/augeas/broken delete mode 100644 spec/fixtures/unit/puppet/provider/pam/augeas/empty delete mode 100644 spec/fixtures/unit/puppet/provider/pam/augeas/full delete mode 100644 spec/fixtures/unit/puppet/provider/pg_hba/augeas/broken delete mode 100644 spec/fixtures/unit/puppet/provider/pg_hba/augeas/empty delete mode 100644 spec/fixtures/unit/puppet/provider/pg_hba/augeas/full delete mode 100644 spec/fixtures/unit/puppet/provider/puppet_auth/augeas/broken delete mode 100644 spec/fixtures/unit/puppet/provider/puppet_auth/augeas/empty delete mode 100644 spec/fixtures/unit/puppet/provider/puppet_auth/augeas/full delete mode 100644 spec/fixtures/unit/puppet/provider/shellvar/augeas/broken delete mode 100644 spec/fixtures/unit/puppet/provider/shellvar/augeas/empty delete mode 100644 spec/fixtures/unit/puppet/provider/shellvar/augeas/full delete mode 100644 spec/fixtures/unit/puppet/provider/sshd_config/augeas/broken delete mode 100644 spec/fixtures/unit/puppet/provider/sshd_config/augeas/empty delete mode 100644 spec/fixtures/unit/puppet/provider/sshd_config/augeas/full delete mode 100644 spec/fixtures/unit/puppet/provider/sshd_config/augeas/nomatch delete mode 100644 spec/fixtures/unit/puppet/provider/sshd_config_subsystem/augeas/broken delete mode 100644 spec/fixtures/unit/puppet/provider/sshd_config_subsystem/augeas/empty delete mode 100644 spec/fixtures/unit/puppet/provider/sshd_config_subsystem/augeas/full delete mode 100644 spec/fixtures/unit/puppet/provider/sysctl/augeas/broken delete mode 100644 spec/fixtures/unit/puppet/provider/sysctl/augeas/empty delete mode 100644 spec/fixtures/unit/puppet/provider/sysctl/augeas/full delete mode 100644 spec/fixtures/unit/puppet/provider/sysctl/augeas/small delete mode 100644 spec/fixtures/unit/puppet/provider/syslog/augeas/broken delete mode 100644 spec/fixtures/unit/puppet/provider/syslog/augeas/empty delete mode 100644 spec/fixtures/unit/puppet/provider/syslog/augeas/full delete mode 100644 spec/fixtures/unit/puppet/provider/syslog/rsyslog/broken delete mode 100644 spec/fixtures/unit/puppet/provider/syslog/rsyslog/empty delete mode 100644 spec/fixtures/unit/puppet/provider/syslog/rsyslog/full delete mode 100644 spec/unit/puppet/provider/apache_directive/augeas_spec.rb delete mode 100644 spec/unit/puppet/provider/apache_setenv/augeas_spec.rb delete mode 100755 spec/unit/puppet/provider/host/augeas_spec.rb delete mode 100755 spec/unit/puppet/provider/kernel_parameter/grub2_spec.rb delete mode 100755 spec/unit/puppet/provider/kernel_parameter/grub_spec.rb delete mode 100755 spec/unit/puppet/provider/mailalias/augeas_spec.rb delete mode 100755 spec/unit/puppet/provider/mounttab/fstab_spec.rb delete mode 100644 spec/unit/puppet/provider/mounttab/vfstab_spec.rb delete mode 100755 spec/unit/puppet/provider/nrpe_command/augeas_spec.rb delete mode 100755 spec/unit/puppet/provider/pam/augeas_spec.rb delete mode 100644 spec/unit/puppet/provider/pg_hba/augeas_spec.rb delete mode 100644 spec/unit/puppet/provider/puppet_auth/augeas_spec.rb delete mode 100755 spec/unit/puppet/provider/shellvar/augeas_spec.rb delete mode 100755 spec/unit/puppet/provider/sshd_config/augeas_spec.rb delete mode 100755 spec/unit/puppet/provider/sshd_config_subsystem/augeas_spec.rb delete mode 100755 spec/unit/puppet/provider/sysctl/augeas_spec.rb delete mode 100644 spec/unit/puppet/provider/syslog/augeas_spec.rb delete mode 100644 spec/unit/puppet/provider/syslog/rsyslog_spec.rb delete mode 100755 spec/unit/puppet/type/shellvar_type_spec.rb diff --git a/.fixtures.yml b/.fixtures.yml index eb15a9b..7b78229 100644 --- a/.fixtures.yml +++ b/.fixtures.yml @@ -1,10 +1,7 @@ fixtures: repositories: - mount_providers: - repo: git://github.com/puppetlabs/puppetlabs-mount_providers.git - ref: 0.0.2 stdlib: repo: git://github.com/puppetlabs/puppetlabs-stdlib.git ref: 4.1.0 symlinks: - augeasproviders: "#{source_dir}" + "augeasprovider_core": "#{source_dir}" diff --git a/lib/augeasproviders.rb b/lib/augeasproviders.rb deleted file mode 100644 index 17ac753..0000000 --- a/lib/augeasproviders.rb +++ /dev/null @@ -1,2 +0,0 @@ -module AugeasProviders -end diff --git a/lib/augeasproviders/mounttab.rb b/lib/augeasproviders/mounttab.rb deleted file mode 100644 index f6131b0..0000000 --- a/lib/augeasproviders/mounttab.rb +++ /dev/null @@ -1,4 +0,0 @@ -require File.dirname(__FILE__) + '/../augeasproviders' - -module AugeasProviders::Mounttab -end diff --git a/lib/augeasproviders/mounttab/fstab.rb b/lib/augeasproviders/mounttab/fstab.rb deleted file mode 100644 index 605b3ad..0000000 --- a/lib/augeasproviders/mounttab/fstab.rb +++ /dev/null @@ -1,125 +0,0 @@ -# mounttab provider for the Fstab lens (i.e. Linux) -# -# This will be wrapped by the real provider which will load it based on -# OS detection. -# -# Copyright (c) 2012 Dominic Cleal -# Licensed under the Apache License, Version 2.0 - -require File.dirname(__FILE__) + '/../../augeasproviders' -require File.dirname(__FILE__) + '/../../augeasproviders/mounttab' - -module AugeasProviders::Mounttab - class Fstab - - attr_reader :resource - - def self.default_file - '/etc/fstab' - end - - def self.lens - 'Fstab.lns' - end - - def self.get_resource(aug, mpath, target) - entry = { - :ensure => :present, - :target => target - } - return nil unless entry[:name] = aug.get("#{mpath}/file") - entry[:device] = aug.get("#{mpath}/spec") - entry[:fstype] = aug.get("#{mpath}/vfstype") - - options = [] - aug.match("#{mpath}/opt").each do |opath| - opt = aug.get(opath) - optv = aug.get("#{opath}/value") - opt = "#{opt}=#{optv}" if optv - options << opt - end - entry[:options] = options - entry[:pass] = aug.get("#{mpath}/passno") if aug.match("#{mpath}/passno") - entry[:dump] = aug.get("#{mpath}/dump") if aug.match("#{mpath}/dump") - - entry - end - - def self.create(aug, resource) - aug.set("$target/01/spec", resource[:device]) - aug.set("$target/01/file", resource[:name]) - aug.set("$target/01/vfstype", resource[:fstype]) - insoptions(aug, "$target/01", resource) - aug.set("$target/01/dump", resource[:dump].to_s) - aug.set("$target/01/passno", resource[:pass].to_s) - end - - def self.insoptions(aug, entry, resource) - # Options are defined as a list property, so they get joined with commas. - # Since Augeas understands elements, access the original array or string. - values = resource.original_parameters[:options] - - aug.rm("#{entry}/opt") - insafter = "vfstype" - if values and not values.empty? - [values].flatten.each do |opt| - optk, optv = opt.split("=", 2) - aug.insert("#{entry}/#{insafter}", "opt", false) - aug.set("#{entry}/opt[last()]", optk) - aug.set("#{entry}/opt[last()]/value", optv) if optv - insafter = "opt[last()]" - end - else - # Strictly this is optional, but only Augeas > 0.10.0 has a lens that - # knows this is the case, so always fill it in. - aug.insert("#{entry}/#{insafter}", "opt", false) - aug.set("#{entry}/opt", "defaults") - end - end - - def self.dump(aug, resource) - aug.get("$target/*[file = '#{resource[:name]}']/dump") - end - - def self.set_dump(aug, resource, value) - # Ensure "defaults" option is always set if dump is being set, as the - # opts field is optional - if aug.match("$target/*[file = '#{resource[:name]}']/opt").empty? - aug.set("$target/*[file = '#{resource[:name]}']/opt", "defaults") - end - - aug.set("$target/*[file = '#{resource[:name]}']/dump", value.to_s) - end - - def self.pass(aug, resource) - aug.get("$target/*[file = '#{resource[:name]}']/passno") - end - - def self.set_pass(aug, resource, value) - # Ensure "defaults" option is always set if passno is being set, as the - # opts field is optional - if aug.match("$target/*[file = '#{resource[:name]}']/opt").empty? - aug.set("$target/*[file = '#{resource[:name]}']/opt", "defaults") - end - - # Ensure dump is always set too - if aug.match("$target/*[file = '#{resource[:name]}']/dump").empty? - aug.set("$target/*[file = '#{resource[:name]}']/dump", "0") - end - - aug.set("$target/*[file = '#{resource[:name]}']/passno", value.to_s) - end - - def self.atboot(aug, resource) - resource.should(:atboot) - end - - def self.set_atboot(aug, resource, value) - return - end - - def self.empty_options - ['', 'defaults'] - end - end -end diff --git a/lib/augeasproviders/mounttab/vfstab.rb b/lib/augeasproviders/mounttab/vfstab.rb deleted file mode 100644 index 7382f21..0000000 --- a/lib/augeasproviders/mounttab/vfstab.rb +++ /dev/null @@ -1,119 +0,0 @@ -# mounttab provider for the Vfstab lens for Solaris -# -# This will be wrapped by the real provider which will load it based on -# OS detection. -# -# Copyright (c) 2012 Dominic Cleal -# Licensed under the Apache License, Version 2.0 - -require File.dirname(__FILE__) + '/../../augeasproviders' -require File.dirname(__FILE__) + '/../../augeasproviders/mounttab' - -module AugeasProviders::Mounttab - class Vfstab - - attr_reader :resource - - def self.default_file - '/etc/vfstab' - end - - def self.lens - 'Vfstab.lns' - end - - def self.get_resource(aug, mpath, target) - entry = { - :ensure => :present, - :target => target - } - return nil unless entry[:name] = aug.get("#{mpath}/file") - entry[:device] = aug.get("#{mpath}/spec") - entry[:fstype] = aug.get("#{mpath}/vfstype") - entry[:blockdevice] = (aug.get("#{mpath}/fsck") or "-") - entry[:pass] = (aug.get("#{mpath}/passno") or "-") - entry[:atboot] = aug.get("#{mpath}/atboot") - - options = [] - aug.match("#{mpath}/opt").each do |opath| - opt = aug.get(opath) - optv = aug.get("#{opath}/value") - opt = "#{opt}=#{optv}" if optv - options << opt - end - entry[:options] = if options.empty? - "-" - else - options - end - - entry - end - - def self.create(aug, resource) - aug.set("$target/01/spec", resource[:device]) - if resource[:blockdevice] and resource[:blockdevice] != "" - aug.set("$target/01/fsck", resource[:blockdevice]) - end - aug.set("$target/01/file", resource[:name]) - aug.set("$target/01/vfstype", resource[:fstype]) - aug.set("$target/01/passno", resource[:pass].to_s) unless resource[:pass] == "-" - aug.set("$target/01/atboot", resource[:atboot].to_s) - insoptions(aug, "$target/01", resource) - end - - def target - file(resource) - end - - def self.insoptions(aug, entry, resource) - # Options are defined as a list property, so they get joined with commas. - # Since Augeas understands elements, access the original array or string. - values = resource.original_parameters[:options] - - aug.rm("#{entry}/opt") - if values and not values.empty? - [values].flatten.each do |opt| - optk, optv = opt.split("=", 2) - aug.set("#{entry}/opt[last()+1]", optk) - aug.set("#{entry}/opt[last()]/value", optv) if optv - end - end - end - - def self.dump(aug, resource) - resource.should(:dump) - end - - def self.set_dump(aug, resource, value) - return - end - - def self.pass(aug, resource) - aug.get("$target/*[file = '#{resource[:name]}']/passno") or "-" - end - - def self.set_pass(aug, resource, value) - if value == "-" - aug.rm("$target/*[file = '#{resource[:name]}']/passno") - else - if aug.match("$target/*[file = '#{resource[:name]}']/passno").empty? - aug.insert("$target/*[file = '#{resource[:name]}']/vfstype", "passno", false) - end - aug.set("$target/*[file = '#{resource[:name]}']/passno", value.to_s) - end - end - - def self.atboot(aug, resource) - aug.get("$target/*[file = '#{resource[:name]}']/atboot") - end - - def self.set_atboot(aug, resource, value) - aug.set("$target/*[file = '#{resource[:name]}']/atboot", value.to_s) - end - - def self.empty_options - ['', '-'] - end - end -end diff --git a/lib/augeasproviders/type.rb b/lib/augeasproviders/type.rb deleted file mode 100644 index 5b9dab6..0000000 --- a/lib/augeasproviders/type.rb +++ /dev/null @@ -1,46 +0,0 @@ -# Additions for types - -require File.dirname(__FILE__) + '/../augeasproviders' - -# Utilities to help write types for Puppet with Augeas-based providers. -# -# To use, include in the type: -# -# Puppet::Type.newtype(:example) do -# extend AugeasProviders::Type -# # [..] -# end -# -# @api public -module AugeasProviders::Type - # Implements `ensurable` with an additional value of `positioned`. - # - # When set to `positioned`, the type will call `provider.in_position?` to - # check if the resource is currently in the correct position in the file. - # If it isn't, the resource will be destroyed and recreated - assuming the - # provider then creates it in the correct position. - # - # @yield additional block to execute within `ensurable` - # @api public - def positionable(&block) - ensurable do - defaultvalues - block if block_given? - - newvalue(:positioned) do - current = self.retrieve - if current == :absent - provider.create - elsif !provider.in_position? - provider.destroy - provider.create - end - end - - def insync?(is) - return true if should == :positioned and is == :present and provider.in_position? - super - end - end - end -end diff --git a/lib/puppet/provider/apache_directive/augeas.rb b/lib/puppet/provider/apache_directive/augeas.rb deleted file mode 100644 index c278411..0000000 --- a/lib/puppet/provider/apache_directive/augeas.rb +++ /dev/null @@ -1,99 +0,0 @@ -# Manages an Apache directive -# -# Copyright (c) 2013 Raphaël Pinson -# Licensed under the Apache License, Version 2.0 - -Puppet::Type.type(:apache_directive).provide(:augeas, :parent => Puppet::Type.type(:augeasprovider).provider(:default)) do - desc 'Use the Augeas API to update a directive in Apache' - - lens { 'Httpd.lns' } - - default_file do - case Facter.value(:osfamily) - when 'RedHat' - '/etc/httpd/conf/httpd.conf' - when 'Debian' - '/etc/apache2/apache2.conf' - end - end - - resource_path do |resource| - path = '$target' - path += "/#{resource[:context]}" unless resource[:context].empty? - if supported?(:regexpi) - path += "/directive[.=~regexp('#{resource[:name]}', 'i')" - else - debug "Warning: Augeas >= 1.0.0 is required for case-insensitive support in apache_directive resources" - path += "/directive[.='#{resource[:name]}'" - end - if resource[:args] - resource[:args][0, resource[:args_params].to_i].each_with_index do |a, i| - path += " and arg[#{i+1}]='#{a}'" - end - end - path += ']' - path - end - - confine :feature => :augeas - - def self.instances - augopen do |aug| - aug.match('$target//directive').map do |spath| - # Find path - context = spath.slice("/files#{target}".length+1..-1).sub(%r{/?directive.*}, '') - args = aug.match("#{spath}/arg").map do |apath| - aug.get(apath) - end - new({ - :name => aug.get(spath), - :ensure => :present, - :args => args, - :context => context, - :args_params => 0 - }) - end - end - end - - def create - augopen! do |aug| - top_path = '$target' - top_path += "/#{resource[:context]}" unless resource[:context].empty? - last_path = "#{top_path}/directive[.='#{resource[:name]}'][last()]" - if aug.match(last_path).empty? - aug.clear("#{top_path}/directive[last()+1]") - else - # Prefer to insert the new node after the last directive with the same name - aug.insert(last_path, 'directive', false) - end - - # The new node is the only directive without a value - aug.defvar('new', "#{top_path}/directive[.='']") - aug.set('$new', resource[:name]) - resource[:args].each_with_index do |a,i| - aug.set("$new/arg[#{i+1}]", a) - end - end - end - - def args - augopen do |aug| - aug.match('$resource[last()]/arg').map do |apath| - aug.get(apath) - end - end - end - - def args=(args) - augopen! do |aug| - aug.rm("#{resource_path}[position()!=last()]") - setvars(aug) - # Remove all options and replace them - aug.rm('$resource/arg') - args.each do |a| - aug.set("$resource/arg[.='#{a}']", a) - end - end - end -end diff --git a/lib/puppet/provider/apache_setenv/augeas.rb b/lib/puppet/provider/apache_setenv/augeas.rb deleted file mode 100644 index 8b0a238..0000000 --- a/lib/puppet/provider/apache_setenv/augeas.rb +++ /dev/null @@ -1,68 +0,0 @@ -# Manages SetEnv entries in a Apache config -# -# Copyright (c) 2013 Endre Karlson -# Licensed under the Apache License, Version 2.0 - -Puppet::Type.type(:apache_setenv).provide(:augeas, :parent => Puppet::Type.type(:augeasprovider).provider(:default)) do - desc "Use Augeas API to update SetEnv in Apache" - - lens { 'Httpd.lns' } - - default_file do - FileTest.exist?("/etc/httpd/conf/httpd.conf") ? "/etc/httpd/conf/httpd.conf" : "/etc/apache2/apache2.conf" - end - - resource_path do |resource| - "$target/directive[.='SetEnv' and arg[1]='#{resource[:name]}']" - end - - confine :feature => :augeas - - def self.instances - augopen do |aug| - resources = [] - aug.match('$target/directive[.="SetEnv"]').each do |spath| - name = aug.get("#{spath}/arg[1]") - unless resources.detect { |r| r.name == name } - resource = {:ensure => :present, :name => name} - resource[:value] = aug.get("#{resource_path(resource)}[last()]/arg[2]") - resources << new(resource) - end - end - resources - end - end - - define_aug_method!(:create) do |aug, resource| - last_path = '$target/directive[.="SetEnv"][last()]' - if aug.match('$target/directive[.="SetEnv"]').empty? - aug.clear('$target/directive[last()+1]') - else - # Prefer to insert the new node after the last SetEnv - aug.insert(last_path, 'directive', false) - end - - # The new node is the only directive without a value - aug.defvar('new', '$target/directive[.=""]') - aug.set('$new', 'SetEnv') - aug.set('$new/arg[1]', resource[:name]) - if resource[:value] - aug.set('$new/arg[2]', resource[:value]) - end - end - - define_aug_method(:value) do |aug, resource| - aug.get('$resource[last()]/arg[2]') || '' - end - - define_aug_method!(:value=) do |aug, resource, value| - # Get last path, then remove the rest - val_path = '$resource[last()]/arg[2]' - if resource[:value].nil? || resource[:value].empty? - aug.rm(val_path) - else - aug.set(val_path, resource[:value]) - end - aug.rm('$resource[position()!=last()]') - end -end diff --git a/lib/puppet/provider/host/augeas.rb b/lib/puppet/provider/host/augeas.rb deleted file mode 100644 index 7d86cb6..0000000 --- a/lib/puppet/provider/host/augeas.rb +++ /dev/null @@ -1,167 +0,0 @@ -# Alternative Augeas-based provider for host type (Puppet builtin) -# -# Copyright (c) 2012 Dominic Cleal -# Licensed under the Apache License, Version 2.0 - -Puppet::Type.type(:host).provide(:augeas, :parent => Puppet::Type.type(:augeasprovider).provider(:default)) do - desc "Uses Augeas API to update hosts file" - - default_file do - case Facter.value(:operatingsystem) - when "Solaris" - "/etc/inet/hosts" - else - "/etc/hosts" - end - end - - lens { 'Hosts.lns' } - - resource_path do |resource| - "$target/*[canonical = '#{resource[:name]}']" - end - - confine :feature => :augeas - defaultfor :feature => :augeas - - def self.get_resource(aug, hpath, target) - host = { - :ensure => :present, - :target => target - } - return nil unless host[:name] = aug.get("#{hpath}/canonical") - host[:ip] = aug.get("#{hpath}/ipaddr") - - aliases = aug.match("#{hpath}/alias").map { |apath| aug.get(apath) } - host[:host_aliases] = aliases unless aliases.empty? - - comment = aug.get("#{hpath}/#comment") - host[:comment] = comment if comment - - host - end - - def self.get_resources(resource=nil) - augopen(resource) do |aug| - resources = aug.match('$target/*').map { - |p| get_resource(aug, p, target(resource)) - }.compact.map { |r| new(r) } - resources - end - end - - def self.instances - get_resources - end - - def self.prefetch(resources) - targets = [] - resources.each do |name, resource| - targets << target(resource) unless targets.include? target(resource) - end - hosts = targets.inject([]) { |hosts,target| hosts += get_resources({:target => target}) } - resources.each do |name, resource| - if provider = hosts.find { |host| (host.name == name and host.target == target(resource)) } - resources[name].provider = provider - end - end - resources - end - - def exists? - @property_hash[:ensure] == :present && @property_hash[:target] == target - end - - def create - augopen! do |aug| - aug.defnode('resource', '$target/01', nil) - aug.set('$resource/ipaddr', resource[:ip]) - aug.set('$resource/canonical', resource[:name]) - - if resource[:host_aliases] - values = resource[:host_aliases] - values = values.split unless values.is_a? Array - values.each do |halias| - aug.set('$resource/alias[last()+1]', halias) - end - end - - # comment property only available in Puppet 2.7+ - if Puppet::Type.type(:host).validattr? :comment and resource[:comment] - aug.set('$resource/#comment', resource[:comment]) - end - end - - @property_hash = { - :ensure => :present, - :name => resource.name, - :target => resource[:target], - :ip => resource[:ip], - :host_aliases => resource[:host_aliases], - } - if Puppet::Type.type(:host).validattr? :comment and resource[:comment] - @property_hash[:comment] = resource[:comment] || "" - end - end - - def destroy - augopen! do |aug| - aug.rm('$resource') - end - @property_hash[:ensure] = :absent - end - - def target - @property_hash[:target] - end - - def ip - @property_hash[:ip] - end - - def ip=(value) - augopen! do |aug| - aug.set('$resource/ipaddr', value) - end - @property_hash[:ip] = value - end - - def host_aliases - aliases = @property_hash[:host_aliases] || [] - if resource.should(:host_aliases).is_a? Array - aliases - else - aliases.join(" ") - end - end - - def host_aliases=(values) - augopen! do |aug| - aug.rm('$resource/alias') - - insafter = "canonical" - values = values.split unless values.is_a? Array - values.each do |halias| - aug.insert("$resource/#{insafter}", "alias", false) - aug.set("$resource/alias[last()]", halias) - insafter = "alias[last()]" - end - end - @property_hash[:host_aliases] = values - end - - def comment - @property_hash[:comment] || "" - end - - def comment=(value) - augopen! do |aug| - if value.empty? - aug.rm('$resource/#comment') - else - aug.set('$resource/#comment', value) - end - end - @property_hash[:comment] = value - end -end diff --git a/lib/puppet/provider/kernel_parameter/grub.rb b/lib/puppet/provider/kernel_parameter/grub.rb deleted file mode 100644 index 82f6156..0000000 --- a/lib/puppet/provider/kernel_parameter/grub.rb +++ /dev/null @@ -1,125 +0,0 @@ -# GRUB legacy / 0.9x support for kernel parameters -# -# Copyright (c) 2012 Dominic Cleal -# Licensed under the Apache License, Version 2.0 - -Puppet::Type.type(:kernel_parameter).provide(:grub, :parent => Puppet::Type.type(:augeasprovider).provider(:default)) do - desc "Uses Augeas API to update kernel parameters in GRUB's menu.lst" - - default_file do - FileTest.exist?("/boot/efi/EFI/redhat/grub.conf") ? "/boot/efi/EFI/redhat/grub.conf" : "/boot/grub/menu.lst" - end - - lens { 'Grub.lns' } - - confine :feature => :augeas - - # Useful XPath to match only recovery entries - MODE_RECOVERY = "(kernel/S or kernel/1 or kernel/single or .=~regexp('.*\((single-user|recovery) mode\).*'))" - MODE_NOT_RECOVERY = "(count(kernel/S)=0 and count(kernel/1)=0 and count(kernel/single)=0 and .!~regexp('.*\((single-user|recovery) mode\).*'))" - - def title_filter - case resource[:bootmode] - when :recovery - "[#{MODE_RECOVERY}]" - when :normal - "[#{MODE_NOT_RECOVERY}]" - else - "" - end - end - - def self.instances - augopen do |aug| - resources = [] - # Get all unique parameter names - params = aug.match("$target/title/kernel/*").map {|pp| pp.split("/")[-1].split("[")[0] }.uniq - - params.each do |pp| - # Then retrieve all unique values as string (1) or array - vals = aug.match("$target/title/kernel/#{pp}").map {|vp| aug.get(vp) }.uniq - vals = vals[0] if vals.size == 1 - - param = {:ensure => :present, :name => pp, :value => vals} - - # Check if this param is used in recovery entries too, irrespective of value - is_recv = !aug.match("$target/title[#{MODE_RECOVERY} and kernel/#{pp}]").empty? - is_norm = !aug.match("$target/title[#{MODE_NOT_RECOVERY} and kernel/#{pp}]").empty? - if is_recv && is_norm - param[:bootmode] = :all - elsif is_recv - param[:bootmode] = :recovery - else - param[:bootmode] = :normal - end - - resources << new(param) - end - resources - end - end - - def exists? - augopen do |aug| - if resource[:ensure] == :absent - # Existence is specific - if it exists on any kernel, so it gets destroyed - !aug.match("$target/title#{title_filter}/kernel/#{resource[:name]}").empty? - else # if present - # Existence is specific - it must exist on all kernels, or we'll fix it - !aug.match("$target/title#{title_filter}/kernel").find do |kpath| - aug.match("#{kpath}/#{resource[:name]}").empty? - end - end - end - end - - def create - self.value=(resource[:value]) - end - - def destroy - augopen! do |aug| - aug.rm("$target/title#{title_filter}/kernel/#{resource[:name]}") - end - end - - def value - augopen do |aug| - aug.match("$target/title#{title_filter}/kernel/#{resource[:name]}").map {|p| aug.get(p) }.uniq - end - end - - def value=(newval) - augopen! do |aug| - aug.match("$target/title#{title_filter}/kernel").each do |kpath| - if newval && !newval.empty? - vals = newval.clone - else - # If no value (e.g. "quiet") then clear the first and delete the rest - vals = nil - aug.clear("#{kpath}/#{resource[:name]}[1]") - aug.rm("#{kpath}/#{resource[:name]}[position() > 1]") - end - - # Set any existing parameters with this name, remove excess ones - if vals - aug.match("#{kpath}/#{resource[:name]}").each do |ppath| - val = vals.shift - if val.nil? - aug.rm(ppath) - else - aug.set(ppath, val) - end - end - end - - # Add new parameters where there are more values than existing params - if vals && !vals.empty? - vals.each do |val| - aug.set("#{kpath}/#{resource[:name]}[last()+1]", val) - end - end - end - end - end -end diff --git a/lib/puppet/provider/kernel_parameter/grub2.rb b/lib/puppet/provider/kernel_parameter/grub2.rb deleted file mode 100644 index 83ae4b1..0000000 --- a/lib/puppet/provider/kernel_parameter/grub2.rb +++ /dev/null @@ -1,119 +0,0 @@ -# GRUB 2 support for kernel parameters, edits /etc/default/grub -# -# Copyright (c) 2012 Dominic Cleal -# Licensed under the Apache License, Version 2.0 - -Puppet::Type.type(:kernel_parameter).provide(:grub2, :parent => Puppet::Type.type(:augeasprovider).provider(:default)) do - desc "Uses Augeas API to update kernel parameters in GRUB2's /etc/default/grub" - - default_file { '/etc/default/grub' } - - lens { 'Shellvars_list.lns' } - - resource_path do |resource| - "$target/#{section(resource)}/value[.=~regexp('^#{resource[:name]}(=.*)?$')]" - end - - def self.mkconfig_path - which("grub2-mkconfig") or which("grub-mkconfig") or '/usr/sbin/grub-mkconfig' - end - - confine :feature => :augeas - commands :mkconfig => mkconfig_path - - def self.instances - augopen do |aug| - resources = [] - - # Params are nicely separated, but no recovery-only setting (hard-coded) - sections = { 'all' => "GRUB_CMDLINE_LINUX", - 'normal' => "GRUB_CMDLINE_LINUX_DEFAULT" } - sections.keys.sort.each do |bootmode| - key = sections[bootmode] - # Get all unique param names - params = aug.match("$target/#{key}/value").map { |pp| - aug.get(pp).split("=")[0] - }.uniq - - # Find all values for each param name - params.each do |param| - vals = aug.match("$target/#{key}/value[.=~regexp('^#{param}(=.*)?$')]").map {|vp| - aug.get(vp).split("=", 2)[1] - } - vals = vals[0] if vals.size == 1 - - param = {:ensure => :present, :name => param, :value => vals, :bootmode => bootmode} - resources << new(param) - end - end - resources - end - end - - def self.section(resource) - case resource[:bootmode].to_s - when "normal" - "GRUB_CMDLINE_LINUX_DEFAULT" - when "all" - "GRUB_CMDLINE_LINUX" - else - fail("Unsupported bootmode for #{self.class.to_s} provider") - end - end - - def create - self.value=(resource[:value]) - end - - def value - augopen do |aug| - aug.match('$resource').map {|vp| - aug.get(vp).split("=", 2)[1] - } - end - end - - def value=(newval) - augopen! do |aug| - if newval && !newval.empty? - vals = newval.clone - else - # If no value (e.g. "quiet") then clear the value from the first and - # delete the rest - vals = nil - aug.set("#{resource_path}[1]", resource[:name]) - aug.rm("#{resource_path}[position() > 1]") - end - - # Set any existing parameters with this name, remove excess ones - if vals - aug.match('$resource').each do |ppath| - val = vals.shift - if val.nil? - aug.rm(ppath) - else - aug.set(ppath, "#{resource[:name]}=#{val}") - end - end - end - - # Add new parameters where there are more values than existing params - if vals && !vals.empty? - vals.each do |val| - aug.set("$target/#{self.class.section(resource)}/value[last()+1]", "#{resource[:name]}=#{val}") - end - end - end - end - - def flush - cfg = nil - ["/boot/grub/grub.cfg", "/boot/grub2/grub.cfg"].each {|c| - cfg = c if FileTest.file? c - } - fail("Cannot find grub.cfg location to use with grub-mkconfig") unless cfg - - super - mkconfig "-o", cfg - end -end diff --git a/lib/puppet/provider/mailalias/augeas.rb b/lib/puppet/provider/mailalias/augeas.rb deleted file mode 100644 index 7c0cfee..0000000 --- a/lib/puppet/provider/mailalias/augeas.rb +++ /dev/null @@ -1,113 +0,0 @@ -# Alternative Augeas-based provider for mailalias type (Puppet builtin) -# -# Copyright (c) 2012 Dominic Cleal -# Licensed under the Apache License, Version 2.0 - -Puppet::Type.type(:mailalias).provide(:augeas, :parent => Puppet::Type.type(:augeasprovider).provider(:default)) do - desc "Uses Augeas API to update mail aliases file" - - confine :feature => :augeas - defaultfor :feature => :augeas - - default_file { '/etc/aliases' } - lens { 'Aliases.lns' } - - resource_path do |resource| - "$target/*[name = '#{resource[:name]}']" - end - - def self.get_resource(aug, apath, target) - malias = { - :ensure => :present, - :target => target - } - return nil unless malias[:name] = aug.get("#{apath}/name") - - rcpts = aug.match("#{apath}/value").map { |p| unquoteit(aug.get(p)) } - malias[:recipient] = rcpts - malias - end - - def self.get_resources(resource=nil) - aug = nil - file = target(resource) - augopen(resource) do |aug| - resources = aug.match("$target/*").map { - |p| get_resource(aug, p, file) - }.compact.map { |r| new(r) } - resources - end - end - - def self.instances - get_resources - end - - def self.prefetch(resources) - targets = [] - resources.each do |name, resource| - targets << target(resource) unless targets.include? target(resource) - end - maliases = [] - targets.each do |target| - maliases += get_resources({:target => target}) - end - maliases = targets.inject([]) { |malias ,target| maliases += get_resources({:target => target}) } - resources.each do |name, resource| - if provider = maliases.find{ |malias| (malias.name == name and malias.target == target(resource)) } - resources[name].provider = provider - end - end - end - - def exists? - @property_hash[:ensure] == :present and @property_hash[:target] == self.class.target(resource) - end - - def create - augopen do |aug| - aug.set("$target/01/name", resource[:name]) - - resource[:recipient].each do |rcpt| - aug.set("$target/01/value[last()+1]", quoteit(rcpt)) - end - - augsave!(aug) - @property_hash = { - :ensure => :present, - :name => resource.name, - :target => self.class.target(resource), - :recipient => resource[:recipient] - } - end - end - - def destroy - augopen do |aug| - aug.rm('$resource') - augsave!(aug) - @property_hash[:ensure] = :absent - end - end - - def target - @property_hash[:target] - end - - def recipient - @property_hash[:recipient] - end - - def recipient=(values) - augopen do |aug| - aug.rm('$resource/value') - - values.each do |rcpt| - aug.set('$resource/value[last()+1]', quoteit(rcpt)) - end - - augsave!(aug) - @property_hash[:recipient] = values - end - end -end diff --git a/lib/puppet/provider/mounttab/augeas.rb b/lib/puppet/provider/mounttab/augeas.rb deleted file mode 100644 index b507d9b..0000000 --- a/lib/puppet/provider/mounttab/augeas.rb +++ /dev/null @@ -1,171 +0,0 @@ -# Alternative Augeas-based provider for mounttab, distributed in -# puppetlabs-mount_providers. -# -# This is a wrapper around different implementations, which lives in the -# AugeasProviders namespace. The idea is to use a single provider called -# "augeas" so site-wide defaults can be set rather than forcing the user to -# set the provider based on OS upfront. The equivalent of confining the -# provider based on OS is instead done here. -# -# Copyright (c) 2012 Dominic Cleal -# Licensed under the Apache License, Version 2.0 - -require File.dirname(__FILE__) + '/../../../augeasproviders/mounttab/fstab' -require File.dirname(__FILE__) + '/../../../augeasproviders/mounttab/vfstab' - -Puppet::Type.type(:mounttab).provide(:augeas, :parent => Puppet::Type.type(:augeasprovider).provider(:default)) do - desc "Uses Augeas API to update the /etc/(v)fstab file" - - def self.osimpl - os = Facter.value(:osfamily) or Facter.value(:operatingsystem) - case os - when "Solaris" - AugeasProviders::Mounttab::Vfstab - else - AugeasProviders::Mounttab::Fstab - end - end - - default_file do - osimpl.default_file - end - - lens do - osimpl.lens - end - - resource_path do |resource| - "$target/*[file = '#{resource[:name]}']" - end - - confine :feature => :augeas - defaultfor :feature => :augeas - - def self.instances - augopen do |aug| - resources = [] - aug.match("$target/*").each do |mpath| - entry = osimpl.get_resource(aug, mpath, target) - resources << new(entry) unless entry.nil? - end - resources - end - end - - def create - augopen! do |aug| - self.class.osimpl.create(aug, resource) - end - end - - def device - augopen do |aug| - aug.get('$resource/spec') - end - end - - def device=(value) - augopen! do |aug| - aug.set('$resource/spec', value) - end - end - - def blockdevice - augopen do |aug| - aug.get('$resource/fsck') or "-" - end - end - - def blockdevice=(value) - augopen! do |aug| - if value == "-" - aug.rm('$resource/fsck') - else - if aug.match('$resource/fsck').empty? - aug.insert('$resource/spec', 'fsck', false) - end - aug.set('$resource/fsck', value.to_s) - end - end - end - - def fstype - augopen do |aug| - aug.get('$resource/vfstype') - end - end - - def fstype=(value) - augopen! do |aug| - aug.set('$resource/vfstype', value) - end - end - - def options - augopen do |aug| - opts = [] - aug.match('$resource/opt').each do |opath| - opt = aug.get(opath) - optv = aug.get("#{opath}/value") - opt = "#{opt}=#{optv}" if optv - opts << opt - end - opts = opts.join(",") - - # [] and ["defaults"] are synonyms, so return what the user requested if - # the current value is one of these to avoid changes - empties = self.class.osimpl.empty_options - if empties.include?(opts) and empties.include?(resource.should(:options)) - resource.should(:options) - else - opts - end - end - end - - def insoptions(aug, entry, resource) - self.class.osimpl.insoptions(aug, entry, resource) - end - - def options=(values) - augopen! do |aug| - insoptions(aug, '$resource', resource) - end - end - - def dump - augopen do |aug| - self.class.osimpl.dump(aug, resource) - end - end - - def dump=(value) - augopen! do |aug| - self.class.osimpl.set_dump(aug, resource, value) - end - end - - def pass - augopen do |aug| - self.class.osimpl.pass(aug, resource) - end - end - - def pass=(value) - augopen! do |aug| - self.class.osimpl.set_pass(aug, resource, value) - end - end - - def atboot - augopen do |aug| - self.class.osimpl.atboot(aug, resource) - end - end - - def atboot=(value) - augopen! do |aug| - self.class.osimpl.set_atboot(aug, resource, value) - end - end -end diff --git a/lib/puppet/provider/nrpe_command/augeas.rb b/lib/puppet/provider/nrpe_command/augeas.rb deleted file mode 100644 index afa973e..0000000 --- a/lib/puppet/provider/nrpe_command/augeas.rb +++ /dev/null @@ -1,41 +0,0 @@ -# Alternative Augeas-based provider for nrpe type -# -# Copyright (c) 2012 Christian Kaenzig -# Licensed under the Apache License, Version 2.0 - -Puppet::Type.type(:nrpe_command).provide(:augeas, :parent => Puppet::Type.type(:augeasprovider).provider(:default)) do - desc "Uses Augeas API to update nrpe commands" - - default_file { '/etc/nagios/nrpe.cfg' } - - lens { 'Nrpe.lns' } - - confine :feature => :augeas - - resource_path do |resource| - "$target/command[#{resource[:name]}]/#{resource[:name]}" - end - - def self.instances - augopen do |aug| - aug.match("$target/command/*").map do |spath| - new({ - :ensure => :present, - :name => path_label(aug, spath), - :command => aug.get(spath) - }) - end - end - end - - define_aug_method!(:create) do |aug, resource| - aug.defnode('resource', resource_path(resource), nil) - attr_aug_writer_command(aug, resource[:command]) - end - - define_aug_method!(:destroy) do |aug, resource| - aug.rm("$target/command[#{resource[:name]}]") - end - - attr_aug_accessor(:command, :label => :resource) -end diff --git a/lib/puppet/provider/pam/augeas.rb b/lib/puppet/provider/pam/augeas.rb deleted file mode 100644 index 5d2fbf2..0000000 --- a/lib/puppet/provider/pam/augeas.rb +++ /dev/null @@ -1,125 +0,0 @@ -# Alternative Augeas-based providers for Puppet -# -# Copyright (c) 2012 Greg Swift -# Licensed under the Apache License, Version 2.0 - -Puppet::Type.type(:pam).provide(:augeas, :parent => Puppet::Type.type(:augeasprovider).provider(:default)) do - desc "Uses Augeas API to update an pam parameter" - - # Boolean is the key because they either do or do not provide a - # value for control to work against. Module doesn't work against - # control - PAM_POSITION_ALIASES = { - true => { 'first' => "*[type='%s' and control='%s'][1]", - 'last' => "*[type='%s' and control='%s'][last()]", - 'module' => "*[type='%s' and module='%s'][1]", }, - false => { 'first' => "*[type='%s'][1]", - 'last' => "*[type='%s'][last()]", }, - } - - confine :feature => :augeas - - default_file { '/etc/pam.d/system-auth' } - - def target(resource = nil) - if resource and resource[:service] - "/etc/pam.d/#{resource[:service]}".chomp('/') - else - super - end - end - - lens do |resource| - target(resource) == '/etc/pam.conf' ? 'pamconf.lns' : 'pam.lns' - end - - resource_path do |resource| - service = resource[:service] - type = resource[:type] - mod = resource[:module] - if target == '/etc/pam.conf' - "$target/*[service='#{service}' and type='#{type}' and module='#{mod}']" - else - "$target/*[type='#{type}' and module='#{mod}']" - end - end - - def self.instances - augopen do |aug| - resources = [] - aug.match("$target/*[label()!='#comment']").each do |spath| - optional = aug.match("#{spath}/optional").empty?.to_s.to_sym - type = aug.get("#{spath}/type") - control = aug.get("#{spath}/control") - mod = aug.get("#{spath}/module") - arguments = aug.match("#{spath}/argument").map { |p| aug.get(p) } - entry = {:ensure => :present, - :optional => optional, - :type => type, - :control => control, - :module => mod, - :arguments => arguments} - if target == '/etc/pam.conf' - entry[:service] = aug.get("#{spath}/service") - end - resources << new(entry) - end - resources - end - end - - define_aug_method!(:create) do |aug, resource| - path = '01' - entry_path = "$target/#{path}" - # we pull type, control, and position out because we actually - # work with those values, not just reference them in the set section - # type comes to us as a symbol, so needs to be converted to a string - type = resource[:type].to_s - control = resource[:control] - position = resource[:position] - placement, identifier, value = position.split(/ /) - key = !!value - if PAM_POSITION_ALIASES[key].has_key?(identifier) - expr = PAM_POSITION_ALIASES[key][identifier] - expr = key ? expr % [type, value] : expr % [type] - else - # if the identifier is not in the mapping - # we assume that its an xpath and so - # join everything after the placement - identifier = position.split(/ /)[1..-1].join(" ") - expr = identifier - end - aug.insert("$target/#{expr}", path, placement == 'before') - if resource[:optional] == :true - aug.touch("#{entry_path}/optional") - end - if target == '/etc/pam.conf' - aug.set("#{entry_path}/service", resource[:service]) - end - aug.set("#{entry_path}/type", type) - aug.set("#{entry_path}/control", control) - aug.set("#{entry_path}/module", resource[:module]) - resource[:arguments].each do |argument| - aug.set("#{entry_path}/argument[last()+1]", argument) - end - end - - define_aug_method(:optional) do |aug, resource| - aug.match("$resource/optional").empty?.to_s.to_sym - end - - define_aug_method!(:optional=) do |aug, resource, value| - if resource[:optional] == :true - if aug.match("$resource/optional").empty? - aug.clear("$resource/optional") - end - else - aug.rm("$resource/optional") - end - end - - attr_aug_accessor(:control) - - attr_aug_accessor(:arguments, :type => :array, :label => 'argument') - -end diff --git a/lib/puppet/provider/pg_hba/augeas.rb b/lib/puppet/provider/pg_hba/augeas.rb deleted file mode 100644 index 9badea6..0000000 --- a/lib/puppet/provider/pg_hba/augeas.rb +++ /dev/null @@ -1,104 +0,0 @@ -# Alternative Augeas-based provider for pg_hba type - -Puppet::Type.type(:pg_hba).provide(:augeas, :parent => Puppet::Type.type(:augeasprovider).provider(:default)) do - desc "Uses Augeas API to update pg_hba settings" - - ORDER_ALIASES = { - "first entry" => "*[type][1]", - "last entry" => "*[type][last()]", - "first local" => "*[type='local'][1]", - "last local" => "*[type='local'][last()]", - "first host" => "*[type='host'][1]", - "last host" => "*[type='host'][last()]", - "first hostssl" => "*[type='hostssl'][1]", - "last hostssl" => "*[type='hostssl'][last()]", - "first hostnossl" => "*[type='hostnossl'][1]", - "last hostnossl" => "*[type='hostnossl'][last()]", - "first anyhost" => "*[type=~regexp('host.*')][1]", - "last anyhost" => "*[type=~regexp('host.*')][last()]", - } - - confine :feature => :augeas - - lens { 'Pg_hba.lns' } - - resource_path do |resource| - type = resource[:type] - database = resource[:database] - user = resource[:user] - address = resource[:address] - - database_condition = database.map { |d| "database='#{d}'" }.join(' and ') - database_condition += " and count(database)=#{database.size}" - - user_condition = user.map { |u| "user='#{u}'" }.join(' and ') - user_condition += " and count(user)=#{user.size}" - - if type == 'local' - "$target/*[type='#{type}' and #{database_condition} and #{user_condition}]" - else - "$target/*[type='#{type}' and #{database_condition} and #{user_condition} and address='#{address}']" - end - end - - def self.position_path (position) - pos_before, pos_condition = position.match(/(before|after)\s+(.*)\s*/).captures - if ORDER_ALIASES.has_key? pos_condition - pos_path = ORDER_ALIASES[pos_condition] - else - pos_path = pos_condition - end - return pos_path, pos_before - end - - def in_position? - unless resource[:position].nil? - aug = nil - pos_path, pos_before = self.class.position_path(resource[:position]) - augopen do |aug| - if pos_before == 'before' - mpath = "#{resource_path}[following-sibling::#{pos_path}]" - else - mpath = "#{resource_path}[preceding-sibling::#{pos_path}]" - end - - !aug.match(mpath).empty? - end - end - end - - define_aug_method!(:create) do |aug, resource| - unless resource[:position].nil? - pos_path, pos_before = position_path(resource[:position]) - aug.insert("$target/#{pos_path}", '01', pos_before == 'before') - end - # Creates node if not inserted yet - aug.defnode('resource', '$target/01', nil) - - aug.set("$resource/type", resource[:type]) - - resource[:database].each do |d| - aug.set("$resource/database[.='#{d}']", d) - end - - resource[:user].each do |u| - aug.set("$resource/user[.='#{u}']", u) - end - - if resource[:type] != 'local' - aug.set("$resource/address", resource[:address]) - end - - attr_aug_writer_method(aug, resource[:method]) - attr_aug_writer_options(aug, resource[:options]) - end - - attr_aug_accessor(:method) - - attr_aug_accessor(:options, - :label => 'method/option', - :default => :undef, - :type => :hash, - :sublabel => 'value' - ) -end diff --git a/lib/puppet/provider/puppet_auth/augeas.rb b/lib/puppet/provider/puppet_auth/augeas.rb deleted file mode 100644 index a3f305e..0000000 --- a/lib/puppet/provider/puppet_auth/augeas.rb +++ /dev/null @@ -1,119 +0,0 @@ -# Alternative Augeas-based providers for Puppet -# -# Copyright (c) 2012 Raphaël Pinson -# Licensed under the Apache License, Version 2.0 - -Puppet::Type.type(:puppet_auth).provide(:augeas, :parent => Puppet::Type.type(:augeasprovider).provider(:default)) do - desc "Uses Augeas API to update a rule in Puppet's auth.conf." - - INS_ALIASES = { - "first allow" => "path[allow][1]", - "last allow" => "path[allow][last()]", - "first deny" => "path[count(allow)=0][1]", - "last deny" => "path[count(allow)=0][last()]", - } - - default_file { '/etc/puppet/auth.conf' } - - lens { 'Puppet_Auth.lns' } - - confine :feature => :augeas - - resource_path do |resource| - path = resource[:path] - "$target/path[.='#{path}']" - end - - def self.instances - resources = [] - augopen do |aug| - settings = aug.match("$target/path") - - settings.each do |node| - # Set $resource for getters - aug.defvar('resource', node) - - path = aug.get(node) - path_regex = aug.match("#{node}/operator[.='~']").empty? ? :false : :true - environments = attr_aug_reader_environments(aug) - methods = attr_aug_reader_methods(aug) - allow = attr_aug_reader_allow(aug) - allow_ip = attr_aug_reader_allow_ip(aug) - authenticated = attr_aug_reader_authenticated(aug) - name = (path_regex == :false) ? "Auth rule for #{path}" : "Auth rule matching #{path}" - entry = {:ensure => :present, :name => name, - :path => path, :path_regex => path_regex, - :environments => environments, :methods => methods, - :allow => allow, :allow_ip => allow_ip, - :authenticated => authenticated} - resources << new(entry) if entry[:path] - end - end - resources - end - - def create - apath = resource[:path] - apath_regex = resource[:path_regex] - before = resource[:ins_before] - after = resource[:ins_after] - environments = resource[:environments] - methods = resource[:methods] - allow = resource[:allow] - allow_ip = resource[:allow_ip] - authenticated = resource[:authenticated] - augopen! do |aug| - if before or after - expr = before || after - if INS_ALIASES.has_key?(expr) - expr = INS_ALIASES[expr] - end - aug.insert("$target/#{expr}", "path", before ? true : false) - aug.set("$target/path[.='']", apath) - end - - aug.set(resource_path, apath) - # Refresh $resource - setvars(aug) - if apath_regex == :true - aug.set('$resource/operator', "~") - end - attr_aug_writer_environments(aug, environments) - attr_aug_writer_methods(aug, methods) - attr_aug_writer_allow(aug, allow) - attr_aug_writer_allow_ip(aug, allow_ip) - attr_aug_writer_authenticated(aug, authenticated) - end - end - - attr_aug_accessor(:environments, - :label => 'environment', - :type => :array, - :sublabel => :seq, - :purge_ident => true - ) - - attr_aug_accessor(:methods, - :label => 'method', - :type => :array, - :sublabel => :seq, - :purge_ident => true - ) - - attr_aug_accessor(:allow, - :type => :array, - :sublabel => :seq, - :purge_ident => true - ) - - attr_aug_accessor(:allow_ip, - :type => :array, - :sublabel => :seq, - :purge_ident => true - ) - - attr_aug_accessor(:authenticated, - :label => 'auth', - :purge_ident => true - ) -end diff --git a/lib/puppet/provider/shellvar/augeas.rb b/lib/puppet/provider/shellvar/augeas.rb deleted file mode 100644 index 10c1ffa..0000000 --- a/lib/puppet/provider/shellvar/augeas.rb +++ /dev/null @@ -1,252 +0,0 @@ -# Alternative Augeas-based provider for shellvar type -# -# Copyright (c) 2012 Dominic Cleal -# Licensed under the Apache License, Version 2.0 - -Puppet::Type.type(:shellvar).provide(:augeas, :parent => Puppet::Type.type(:augeasprovider).provider(:default)) do - desc "Uses Augeas API to update shell script variables" - - confine :feature => :augeas - - lens { 'Shellvars.lns' } - - resource_path do |resource| - if resource.provider.unset_seq? - "$target/#{resource[:variable]}|$target/@unset/*[.='#{resource[:variable]}']" - else - "$target/#{resource[:variable]}|$target/@unset[.='#{resource[:variable]}']" - end - end - - def unset_seq? - return @unset_seq unless @unset_seq.nil? - @unset_seq = Puppet::Util::Package.versioncmp(aug_version, '1.2.0') >= 0 - @unset_seq ||= parsed_as?("unset FOO\n", '@unset/1') - end - - def unset_path - if unset_seq? - "$target/@unset/*[.='#{resource[:variable]}']" - else - "$target/@unset[.='#{resource[:variable]}']" - end - end - - def unset_ins_path - if unset_seq? - "$target/@unset[*='#{resource[:variable]}']" - else - "$target/@unset[.='#{resource[:variable]}']" - end - end - - def unset_empty - if unset_seq? - "$target/@unset[count(*)=0]/1" - else - "$target/@unset[.='']" - end - end - - def unset_purge(aug) - aug.rm("$target/@unset[count(*)=0]") if unset_seq? - end - - def is_array?(path=nil, aug=nil) - if aug.nil? || path.nil? - augopen do |aug| - not aug.match("$target/#{resource[:name]}/1").empty? - end - else - not aug.match("$target/#{resource[:name]}/1").empty? - end - end - - def is_exported? - augopen do |aug| - not aug.match("$target/#{resource[:variable]}/export").empty? - end - end - - def is_unset? - augopen do |aug| - if unset_seq? - not aug.match("$target/@unset/*[.='#{resource[:variable]}']").empty? - else - not aug.match("$target/@unset[.='#{resource[:variable]}']").empty? - end - end - end - - def export - augopen! do |aug| - unless aug.match(unset_ins_path).empty? - aug.insert(unset_ins_path, resource[:variable], false) - set_values('$target', aug, resource[:value]) - aug.rm(unset_path) - unset_purge(aug) - end - aug.clear("$target/#{resource[:variable]}/export") - end - end - - def unset - augopen! do |aug| - aug.insert("$target/#{resource[:variable]}", '@unset', false) - aug.set(unset_empty, resource[:variable]) - aug.rm("$target/#{resource[:variable]}") - end - end - - def unexport - augopen! do |aug| - aug.rm("$target/#{resource[:variable]}/export") - # Values may have changed, too - set_values('$target', aug, resource[:value]) - end - end - - def ununset - augopen! do |aug| - aug.insert(unset_ins_path, resource[:variable], false) - set_values('$target', aug, resource[:value]) - aug.rm(unset_path) - unset_purge(aug) - end - end - - def array_type(path=nil, aug=nil) - if resource[:array_type] == :auto - if is_array?(path, aug) - :array - else - :string - end - else - resource[:array_type] - end - end - - def get_values(path, aug) - if is_array?(path, aug) - aug.match('$resource/*').map { |p| aug.get(p) } - else - value = aug.get('$resource') - if value =~ /^(["'])(.*)(\1)$/ - value = $2 - end - [value] - end - end - - def set_values(path, aug, values) - oldvalue = nil - - # Detect array type *before* removing subnodes - my_array_type = array_type(path, aug) - # Remove in any case, because we might convert an array to a string - aug.rm("#{path}/#{resource[:variable]}/*") - case my_array_type - when :string - oldvalue = aug.get("#{path}/#{resource[:variable]}") - aug.set("#{path}/#{resource[:variable]}", quoteit(values.join(' '), oldvalue)) - when :array - values.each_with_index do |v, i| - aug.set("#{path}/#{resource[:variable]}/#{i}", quoteit(v)) - end - end - end - - def create - augopen! do |aug| - # Prefer to create the node next to a commented out entry - commented = aug.match("$target/#comment[.=~regexp('#{resource[:name]}([^a-z\.].*)?')]") - comment_ins = '$resource' - - if resource[:ensure] == :unset - if unset_seq? - comment_ins = '$resource/..' - end - - unless commented.empty? - aug.insert(commented.first, '@unset', false) - aug.rm(commented.first) if resource[:uncomment] == :true - end - aug.set(unset_empty, resource[:variable]) - else - unless commented.empty? - aug.insert(commented.first, resource[:name], false) - aug.rm(commented.first) if resource[:uncomment] == :true - end - set_values('$target', aug, resource[:value]) - aug.clear("$target/#{resource[:variable]}/export") if resource[:ensure] == :exported - end - - setvars(aug) - if resource[:comment] - aug.insert(comment_ins, "#comment", true) - aug.set("$target/#comment[.='']", - "#{resource[:variable]}: #{resource[:comment]}") - end - end - end - - def after_comment_node(resource) - if resource[:ensure] == :unset - if unset_seq? - "@unset[*='#{resource[:variable]}']" - else - "@unset[.='#{resource[:variable]}']" - end - else - resource[:variable] - end - end - - def destroy - augopen! do |aug| - after_comment = after_comment_node(resource) - aug.rm("$target/#comment[following-sibling::*[1][self::#{after_comment}]][. =~ regexp('#{resource[:variable]}:.*')]") - aug.rm("$target/#{resource[:variable]}") - aug.rm(unset_path) - unset_purge(aug) - end - end - - def value - augopen do |aug| - get_values('$target', aug) - end - end - - def value=(value) - augopen! do |aug| - set_values('$target', aug, value) - end - end - - def comment - augopen do |aug| - after_comment = after_comment_node(resource) - comment = aug.get("$target/#comment[following-sibling::*[1][self::#{after_comment}]][. =~ regexp('#{resource[:variable]}:.*')]") - comment.sub!(/^#{resource[:variable]}:\s*/, "") if comment - comment || "" - end - end - - def comment=(value) - augopen! do |aug| - after_comment = after_comment_node(resource) - cmtnode = "$target/#comment[following-sibling::*[1][self::#{after_comment}]][. =~ regexp('#{resource[:variable]}:.*')]" - if value.empty? - aug.rm(cmtnode) - else - if aug.match(cmtnode).empty? - aug.insert("$target/#{resource[:variable]}", "#comment", true) - end - aug.set("$target/#comment[following-sibling::*[1][self::#{after_comment}]]", - "#{resource[:variable]}: #{resource[:comment]}") - end - end - end -end diff --git a/lib/puppet/provider/sshd_config/augeas.rb b/lib/puppet/provider/sshd_config/augeas.rb deleted file mode 100644 index 8cf2031..0000000 --- a/lib/puppet/provider/sshd_config/augeas.rb +++ /dev/null @@ -1,205 +0,0 @@ -# Alternative Augeas-based providers for Puppet -# -# Copyright (c) 2012 Raphaël Pinson -# Licensed under the Apache License, Version 2.0 - - -Puppet::Type.type(:sshd_config).provide(:augeas, :parent => Puppet::Type.type(:augeasprovider).provider(:default)) do - desc "Uses Augeas API to update an sshd_config parameter" - - default_file { '/etc/ssh/sshd_config' } - - lens { 'Sshd.lns' } - - confine :feature => :augeas - - resource_path do |resource| - base = self.base_path(resource) - key = resource[:key] ? resource[:key] : resource[:name] - if supported?(:regexpi) - "#{base}/*[label()=~regexp('#{key}', 'i')]" - else - debug "Warning: Augeas >= 1.0.0 is required for case-insensitive support in sshd_config resources" - "#{base}/#{key}" - end - end - - def self.base_path(resource) - if resource[:condition] - "$target/Match#{self.match_conditions(resource)}/Settings" - else - '$target' - end - end - - def self.get_value(aug, pathx) - aug.match(pathx).map do |vp| - # Augeas lens does transparent multi-node (no counte reset) so check for any int - if aug.match("#{vp}/*[label()=~regexp('[0-9]*')]").empty? - aug.get(vp) - else - aug.match("#{vp}/*").map do |svp| - aug.get(svp) - end - end - end.flatten - end - - def self.set_value(aug, base, path, label, value) - if label =~ /(((Allow|Deny)(Groups|Users))|AcceptEnv|MACs)/i - - if aug.match("#{base}/Match").empty? - # insert as the last line - aug.insert("#{base}/*", label, false) - else - # before the match block so it's in the main section - aug.insert("#{base}/Match[1]", label, true) - end - - # Make sure only our values are used - aug.rm("#{path}/*") - # In case there is more than one entry, keep only the first one - aug.rm("#{path}[position() != 1]") - count = 0 - value.each do |v| - count += 1 - aug.set("#{path}/#{count}", v) - end - else - # Normal setting: one value per entry - value = value.clone - - # Change any existing settings with this name - lastsp = nil - aug.match(path).each do |sp| - val = value.shift - if val.nil? - aug.rm(sp) - else - aug.set(sp, val) - lastsp = sp - end - end - - # Insert new values for the rest - value.each do |v| - if lastsp - # After the most recent same setting (lastsp) - aug.insert(lastsp, label, false) - aug.set("#{path}[last()]", v) - else - # Prefer to create the node next to a commented out entry - commented = aug.match("#{base}/#comment[.=~regexp('#{label}([^a-z\.].*)?')]") - if commented.empty? - if aug.match("#{base}/Match").empty? - # insert as the last line - aug.insert("#{base}/*", label, false) - else - # before the match block so it's in the main section - aug.insert("#{base}/Match[1]", label, true) - end - else - aug.insert(commented.first, label, false) - end - aug.set("#{path}[last()]", v) - end - lastsp = aug.match("#{path}[last()]")[0] - end - end - end - - def self.instances - augopen do |aug,path| - resources = [] - # Ordinary settings outside of match blocks - # Find all unique setting names, then find all instances of it - settings = aug.match("$target/*[label()!='Match']").map {|spath| - path_label(aug, spath) - }.uniq.reject {|name| name.start_with?("#", "@")} - - settings.each do |name| - value = self.get_value(aug, "$target/#{name}") - entry = {:ensure => :present, :name => name, :value => value} - resources << new(entry) if entry[:value] - end - - # Settings inside match blocks - aug.match("$target/Match").each do |mpath| - conditions = [] - aug.match("#{mpath}/Condition/*").each do |cond_path| - cond_name = path_label(aug, cond_path) - cond_value = aug.get(cond_path) - conditions.push("#{cond_name} #{cond_value}") - end - cond_str = conditions.join(" ") - - settings = aug.match("#{mpath}/Settings/*").map {|spath| - path_label(aug, spath) - }.uniq.reject {|name| name.start_with?("#", "@")} - - settings.each do |name| - value = self.get_value(aug, "#{mpath}/Settings/#{name}") - entry = {:ensure => :present, :name => name, - :value => value, :condition => cond_str} - resources << new(entry) if entry[:value] - end - end - resources - end - end - - def self.match_conditions(resource=nil) - if resource[:condition] - conditions = Hash[*resource[:condition].split(' ').flatten(1)] - cond_keys = conditions.keys.length - cond_str = "[count(Condition/*)=#{cond_keys}]" - conditions.each { |k,v| cond_str += "[Condition/#{k}=\"#{v}\"]" } - cond_str - else - "" - end - end - - def self.match_exists?(aug, resource) - cond_str = resource[:condition] ? self.match_conditions(resource) : '' - not aug.match("$target/Match#{cond_str}").empty? - end - - def create - base_path = self.class.base_path(resource) - augopen! do |aug| - key = resource[:key] ? resource[:key] : resource[:name] - if resource[:condition] && !self.class.match_exists?(aug, resource) - aug.insert("$target/*[last()]", "Match", false) - conditions = Hash[*resource[:condition].split(' ').flatten(1)] - conditions.each do |k,v| - aug.set("$target/Match[last()]/Condition/#{k}", v) - end - end - if key.downcase == 'port' and not aug.match("#{base_path}/ListenAddress").empty? - aug.insert("#{base_path}/ListenAddress[1]", key, true) - end - self.class.set_value(aug, base_path, "#{base_path}/#{key}", key, resource[:value]) - end - end - - def destroy - augopen! do |aug| - aug.rm('$resource') - aug.rm('$target/Match[count(Settings/*)=0]') - end - end - - def value - augopen do |aug| - self.class.get_value(aug, '$resource') - end - end - - def value=(value) - augopen! do |aug| - key = resource[:key] ? resource[:key] : resource[:name] - self.class.set_value(aug, self.class.base_path(resource), resource_path, key, value) - end - end -end diff --git a/lib/puppet/provider/sshd_config_subsystem/augeas.rb b/lib/puppet/provider/sshd_config_subsystem/augeas.rb deleted file mode 100644 index f5e14b2..0000000 --- a/lib/puppet/provider/sshd_config_subsystem/augeas.rb +++ /dev/null @@ -1,55 +0,0 @@ -# Alternative Augeas-based providers for Puppet -# -# Copyright (c) 2012 Raphaël Pinson -# Licensed under the Apache License, Version 2.0 - -Puppet::Type.type(:sshd_config_subsystem).provide(:augeas, :parent => Puppet::Type.type(:augeasprovider).provider(:default)) do - desc "Uses Augeas API to update a Subsystem parameter in sshd_config." - - default_file { '/etc/ssh/sshd_config' } - - lens { 'Sshd.lns' } - - confine :feature => :augeas - - resource_path do |resource| - if supported?(:regexpi) - "$target/*[label()=~regexp('Subsystem', 'i')]/#{resource[:name]}" - else - "$target/Subsystem/#{resource[:name]}" - end - end - - def self.instances - augopen do |aug| - aug.match("$target/Subsystem/*").map do |hpath| - command = aug.get(hpath) - new({ - :ensure => :present, - :name => path_label(aug, hpath), - :command => command - }) if command - end - end - end - - define_aug_method!(:create) do |aug, resource| - key = resource[:name] - unless aug.match("$target/Match").empty? - aug.insert("$target/Match[1]", "Subsystem", true) - aug.clear("$target/Subsystem[last()]/#{key}") - end - aug.set("$target/Subsystem/#{resource[:name]}", resource[:command]) - end - - define_aug_method!(:destroy) do |aug, resource| - key = resource[:name] - if supported?(:regexpi) - aug.rm("$target/*[label()=~regexp('Subsystem', 'i') and #{key}]") - else - aug.rm("$target/Subsystem[#{key}]") - end - end - - attr_aug_accessor(:command, :label => :resource) -end diff --git a/lib/puppet/provider/sysctl/augeas.rb b/lib/puppet/provider/sysctl/augeas.rb deleted file mode 100644 index 0c17138..0000000 --- a/lib/puppet/provider/sysctl/augeas.rb +++ /dev/null @@ -1,122 +0,0 @@ -# Alternative Augeas-based provider for sysctl type -# -# Copyright (c) 2012 Dominic Cleal -# Licensed under the Apache License, Version 2.0 - -Puppet::Type.type(:sysctl).provide(:augeas, :parent => Puppet::Type.type(:augeasprovider).provider(:default)) do - desc "Uses Augeas API to update sysctl settings" - - default_file { '/etc/sysctl.conf' } - - lens { 'Sysctl.lns' } - - optional_commands :sysctl => 'sysctl' - - resource_path do |resource| - "$target/#{resource[:name]}" - end - - def self.sysctl_set(key, value) - if Facter.value(:kernel) == :openbsd - sysctl("#{key}=#{value}") - else - sysctl('-w', %Q{#{key}=#{value}}) - end - end - - def self.sysctl_get(key) - sysctl('-n', key).chomp - end - - confine :feature => :augeas - - def self.instances - augopen do |aug| - resources = [] - aug.match("$target/*").each do |spath| - resource = {:ensure => :present} - - basename = spath.split("/")[-1] - resource[:name] = basename.split("[")[0] - next unless resource[:name] - next if resource[:name] == "#comment" - - resource[:value] = aug.get("#{spath}") - - # Only match comments immediately before the entry and prefixed with - # the sysctl name - cmtnode = aug.match("$target/#comment[following-sibling::*[1][self::#{basename}]]") - unless cmtnode.empty? - comment = aug.get(cmtnode[0]) - if comment.match(/#{resource[:name]}:/) - resource[:comment] = comment.sub(/^#{resource[:name]}:\s*/, "") - end - end - - resources << new(resource) - end - resources - end - end - - def create - # the value to pass to augeas can come either from the 'value' or the - # 'val' type parameter. - value = resource[:value] || resource[:val] - - augopen! do |aug| - # Prefer to create the node next to a commented out entry - commented = aug.match("$target/#comment[.=~regexp('#{resource[:name]}([^a-z\.].*)?')]") - aug.insert(commented.first, resource[:name], false) unless commented.empty? - aug.set(resource_path, value) - setvars(aug) - - if resource[:comment] - aug.insert('$resource', "#comment", true) - aug.set("$target/#comment[following-sibling::*[1][self::#{resource[:name]}]]", - "#{resource[:name]}: #{resource[:comment]}") - end - end - end - - define_aug_method!(:destroy) do |aug, resource| - aug.rm("$target/#comment[following-sibling::*[1][self::#{resource[:name]}]][. =~ regexp('#{resource[:name]}:.*')]") - aug.rm('$resource') - end - - def live_value - self.class.sysctl_get(resource[:name]) - end - - attr_aug_accessor(:value, :label => :resource) - - alias_method :val, :value - alias_method :val=, :value= - - define_aug_method(:comment) do |aug, resource| - comment = aug.get("$target/#comment[following-sibling::*[1][self::#{resource[:name]}]][. =~ regexp('#{resource[:name]}:.*')]") - comment.sub!(/^#{resource[:name]}:\s*/, "") if comment - comment || "" - end - - define_aug_method!(:comment=) do |aug, resource, value| - cmtnode = "$target/#comment[following-sibling::*[1][self::#{resource[:name]}]][. =~ regexp('#{resource[:name]}:.*')]" - if value.empty? - aug.rm(cmtnode) - else - if aug.match(cmtnode).empty? - aug.insert('$resource', "#comment", true) - end - aug.set("$target/#comment[following-sibling::*[1][self::#{resource[:name]}]]", - "#{resource[:name]}: #{resource[:comment]}") - end - end - - def flush - super - value = resource[:value] || resource[:val] - if resource[:apply] == :true and not value.nil? - self.class.sysctl_set(resource[:name], value) - end - end -end diff --git a/lib/puppet/provider/syslog/augeas.rb b/lib/puppet/provider/syslog/augeas.rb deleted file mode 100644 index 5a3e403..0000000 --- a/lib/puppet/provider/syslog/augeas.rb +++ /dev/null @@ -1,107 +0,0 @@ -# Alternative Augeas-based providers for Puppet -# -# Copyright (c) 2012 Raphaël Pinson -# Licensed under the Apache License, Version 2.0 - -Puppet::Type.type(:syslog).provide(:augeas, :parent => Puppet::Type.type(:augeasprovider).provider(:default)) do - desc "Uses Augeas API to update a syslog.conf entry" - - default_file { '/etc/syslog.conf' } - - lens do |resource| - if resource and resource[:lens] - resource[:lens] - else - 'Syslog.lns' - end - end - - confine :feature => :augeas - - resource_path do |resource| - entry_path(resource) - end - - # We need to define an entry_path method - # so the rsyslog provider can use it - def self.entry_path(resource) - facility = resource[:facility] - level = resource[:level] - action_type = resource[:action_type] - action = resource[:action] - - # TODO: make it case-insensitive - "$target/entry[selector/facility='#{facility}' and selector/level='#{level}' and action/#{action_type}='#{action}']" - end - - def self.instances - augopen do |aug| - resources = [] - - aug.match("$target/entry").each do |apath| - aug.match("#{apath}/selector").each do |snode| - aug.match("#{snode}/facility").each do |fnode| - facility = aug.get(fnode) - level = aug.get("#{snode}/level") - no_sync = aug.match("#{apath}/action/no_sync").empty? ? :false : :true - action_type_node = aug.match("#{apath}/action/*[label() != 'no_sync']") - action_type = path_label(aug, action_type_node[0]) - action = aug.get("#{apath}/action/#{action_type}") - name = "#{facility}.#{level} " - name += "-" if no_sync == :true - name += "@" if action_type == "hostname" - name += "#{action}" - entry = {:ensure => :present, :name => name, - :facility => facility, :level => level, - :no_sync => no_sync, - :action_type => action_type, :action => action} - resources << new(entry) - end - end - end - - resources - end - end - - def create - facility = resource[:facility] - level = resource[:level] - no_sync = resource[:no_sync] - action_type = resource[:action_type] - action = resource[:action] - augopen! do |aug| - # TODO: make it case-insensitive - aug.set("#{resource_path}/selector/facility", facility) - aug.set("$target/*[last()]/selector/level", level) - if no_sync == :true and action_type == 'file' - aug.clear("$target/*[last()]/action/no_sync") - end - aug.set("$target/*[last()]/action/#{action_type}", action) - end - end - - def no_sync - augopen do |aug| - if aug.match('$resource/action/no_sync').empty? - :false - else - :true - end - end - end - - def no_sync=(no_sync) - augopen! do |aug| - if no_sync == :true - if aug.match('$resource/action/no_sync').empty? - # Insert a no_sync node before the action/file node - aug.insert('$resource/action/file', "no_sync", true) - end - else - # Remove the no_sync tag - aug.rm('$resource/action/no_sync') - end - end - end -end diff --git a/lib/puppet/provider/syslog/rsyslog.rb b/lib/puppet/provider/syslog/rsyslog.rb deleted file mode 100644 index eb4086c..0000000 --- a/lib/puppet/provider/syslog/rsyslog.rb +++ /dev/null @@ -1,17 +0,0 @@ -# Alternative Augeas-based providers for Puppet -# -# Copyright (c) 2012 Raphaël Pinson -# Licensed under the Apache License, Version 2.0 - -Puppet::Type.type(:syslog).provide(:rsyslog, :parent => :augeas) do - desc "Uses Augeas API to update an rsyslog.conf entry" - - default_file { '/etc/rsyslog.conf' } - lens { 'Rsyslog.lns' } - - resource_path do |resource| - entry_path(resource) - end - - confine :feature => :augeas -end diff --git a/lib/puppet/type/apache_directive.rb b/lib/puppet/type/apache_directive.rb deleted file mode 100644 index 3571172..0000000 --- a/lib/puppet/type/apache_directive.rb +++ /dev/null @@ -1,41 +0,0 @@ -# Manages Apache directives -# -# Copyright (c) 2013 Raphaël Pinson -# Licensed under the Apache License, Version 2.0 - -require File.dirname(__FILE__) + '/../../augeasproviders/type' - -Puppet::Type.newtype(:apache_directive) do - @doc = 'Manages Apache directives' - - extend AugeasProviders::Type - - ensurable - - newparam(:name) do - desc 'The directive name' - isnamevar - end - - newparam(:context) do - desc 'The path where the directive is located. Expressed as an Augeas path expression.' - defaultto '' - end - - newproperty(:args, :array_matching => :all) do - desc 'An array of directive arguments' - end - - newparam(:args_params) do - desc 'How many arguments are to be used as params' - defaultto 0 - - validate do |value| - raise "Wrong args_params value '#{value}'" unless value.to_i >= 0 - end - end - - newparam(:target) do - desc 'The config file to use' - end -end diff --git a/lib/puppet/type/apache_setenv.rb b/lib/puppet/type/apache_setenv.rb deleted file mode 100644 index 40ec00b..0000000 --- a/lib/puppet/type/apache_setenv.rb +++ /dev/null @@ -1,32 +0,0 @@ -# Manages SetEnv entries in a Apache config -# -# Copyright (c) 2013 Endre Karlson -# Licensed under the Apache License, Version 2.0 - -require "puppet" - - -module Puppet - Puppet::Type.newtype(:apache_setenv) do - @doc = "Manages SetEnv entries in a Apache config" - - ensurable - - newparam(:name) do - desc "The variable name to set" - isnamevar - end - - newproperty(:value) do - desc "The value to set it to" - end - - newparam(:target) do - desc "The config file to use" - end - - autorequire(:file) do - self[:target] - end - end -end diff --git a/lib/puppet/type/kernel_parameter.rb b/lib/puppet/type/kernel_parameter.rb deleted file mode 100644 index 7fd4331..0000000 --- a/lib/puppet/type/kernel_parameter.rb +++ /dev/null @@ -1,35 +0,0 @@ -# Manages kernel parameters stored in bootloaders such as GRUB. -# -# Copyright (c) 2012 Dominic Cleal -# Licensed under the Apache License, Version 2.0 - -Puppet::Type.newtype(:kernel_parameter) do - @doc = "Manages kernel parameters stored in bootloaders." - - ensurable - - newparam(:name) do - desc "The parameter name, e.g. 'quiet' or 'vga'." - isnamevar - end - - newproperty(:value, :array_matching => :all) do - desc "Value of the parameter if applicable. Many parameters are just keywords so this must be left blank, while others (e.g. 'vga') will take a value." - end - - newparam(:target) do - desc "The bootloader configuration file, if in a non-default location for the provider." - end - - newparam(:bootmode) do - desc "Boot mode(s) to apply the parameter to. Either 'all' (default) to use the parameter on all boots (normal and recovery mode), 'normal' for just normal boots or 'recovery' for just recovery boots." - - newvalues :all, :normal, :recovery - - defaultto :all - end - - autorequire(:file) do - self[:target] - end -end diff --git a/lib/puppet/type/nrpe_command.rb b/lib/puppet/type/nrpe_command.rb deleted file mode 100644 index 24d90a3..0000000 --- a/lib/puppet/type/nrpe_command.rb +++ /dev/null @@ -1,28 +0,0 @@ -# Manages command entries in nrpe.cfg -# -# Copyright (c) 2012 Christian Kaenzig -# Licensed under the Apache License, Version 2.0 - -Puppet::Type.newtype(:nrpe_command) do - @doc = "Manages commands in /etc/nagios/nrpe.cfg." - - ensurable - - newparam(:name) do - desc "The name of the command, e.g. check_my_stuff" - isnamevar - end - - newproperty(:command) do - desc "Check command to run on the system, with arguments" - end - - newparam(:target) do - desc "The file in which to store the command, defaults to - `/etc/nagios/nrpe.cfg`." - end - - autorequire(:file) do - self[:target] - end -end diff --git a/lib/puppet/type/pam.rb b/lib/puppet/type/pam.rb deleted file mode 100644 index 9c3028f..0000000 --- a/lib/puppet/type/pam.rb +++ /dev/null @@ -1,99 +0,0 @@ -# Manages settings in PAM service files -# -# Copyright (c) 2012 Greg Swift -# Licensed under the Apache License, Version 2.0 - -require File.dirname(__FILE__) + '/../../augeasproviders/type' - -Puppet::Type.newtype(:pam) do - @doc = "Manages settings in an PAM service files. - -The resource name is a descriptive string only due to the non-uniqueness of any single paramter." - - extend AugeasProviders::Type - - positionable - - def munge_boolean(value) - case value - when true, "true", :true - :true - when false, "false", :false - :false - else - fail("munge_boolean only takes booleans") - end - end - - newparam(:name) do - desc "The name of the resource, has no bearing on anything" - isnamevar - end - - newparam(:service) do - desc "The PAM service this entry will be placed in. Typically this is the same as the -filename under /etc/pam.d" - end - - newparam(:type) do - desc "The PAM service type of the setting: account, auth, password, session." - newvalues(:account, :auth, :password, :session) - end - - newparam(:module) do - desc "The name of the specific PAM module to load." - end - - newproperty(:optional, :boolean => true) do - desc "Whether failure to load the module will break things" - - newvalue(:true) - newvalue(:false) - - munge do |value| - @resource.munge_boolean(value) - end - end - - newproperty(:arguments, :array_matching => :all) do - desc "Arguments to assign for the module." - end - - newproperty(:control) do - desc "Simple or complex definition of the module's behavior on failure." - end - - newparam(:position) do - desc "A three part text field that providers the placement position of an entry. - -The field consists of `placement identifier value` - -Placement can be either `before` or `after` -Identifier can be either `first`, `last`, `module`, or an Augeas xpath -Value is matched as follows: - With `first` and `last` match `value` to the `control` field, can be blank for absolute positioning. - With `module` matches the `module` field of the associated line, can not be blank. - With an Augeas xpath this field will be ignored, and should be blank. -" - defaultto('before last') - validate do |value| - placement, identifier, val = value.split(/ /) - unless ['before', 'after'].include? placement - raise ArgumentError, "%s is not a valid placement in position" % placement - end -# Don't do validation of the second field because we are supporting xpath -# and thats hard to validate -# unless ['first', 'last', 'module'].include? identifier or identifier =~ // -# raise ArgumentError, "%s is not a valid identifier in position" % indentifier -# end - if val.nil? and identifier == 'module' - raise ArgumentError, "Value must be set if you are matching on module" - end - end - end - - newparam(:target) do - desc "The file in which to store the settings, defaults to `/etc/pam.d/{service}`." - end - -end diff --git a/lib/puppet/type/pg_hba.rb b/lib/puppet/type/pg_hba.rb deleted file mode 100644 index c7f4174..0000000 --- a/lib/puppet/type/pg_hba.rb +++ /dev/null @@ -1,137 +0,0 @@ -# Manages pg_hba entries - -require File.dirname(__FILE__) + '/../../augeasproviders/type' - -Puppet::Type.newtype(:pg_hba) do - @doc = "Manages commands in pg_hba.conf." - - extend AugeasProviders::Type - - positionable - - newparam(:name) do - desc "The default namevar" - end - - newparam(:type) do - desc "The type of host" - isnamevar - newvalues('local', 'host', 'hostssl', 'hostnossl') - defaultto('local') - munge do |value| - value.to_s - end - end - - newparam(:database) do - isnamevar - desc "The database" - defaultto(['all']) - - munge do |value| - if value.is_a? Array - value - else - [value] - end - end - end - - newparam(:user) do - isnamevar - desc "The user" - defaultto(['all']) - - munge do |value| - if value.is_a? Array - value - else - [value] - end - end - end - - newparam(:address) do - isnamevar - desc "The address (for host, hostssl, hostnossl types)" - validate do |value| - unless value.nil? or @resource[:type] != 'local' - raise ArgumentError, "address makes no sense for a local type" - end - end - end - - newparam(:target) do - isnamevar - desc "The file in which to the pg_hba rule" - end - - def self.title_patterns - identity = lambda { |x| x } - comma_split = lambda { |x| x.split(',') } - [ - [ - /^(local)\s+to\s+(\S+)\s+on\s+(\S+)\s+in\s+(.*)$/, - [ - [ :type, identity ], - [ :user, comma_split ], - [ :database, comma_split ], - [ :target, identity ], - ] - ], - [ - /^(local)\s+to\s+(\S+)\s+on\s+(\S+)$/, - [ - [ :type, identity ], - [ :user, comma_split ], - [ :database, comma_split ], - ] - ], - [ - /^(host\S*)\s+to\s+(\S+)\s+on\s+(\S+)\s+from\s+(\S+)\s+in\s+(.*)$/, - [ - [ :type, identity ], - [ :user, comma_split ], - [ :database, comma_split ], - [ :address, identity ], - [ :target, identity ] - ] - ], - [ - /^(host\S*)\s+to\s+(\S+)\s+on\s+(\S+)\s+from\s+(\S+)$/, - [ - [ :type, identity ], - [ :user, comma_split ], - [ :database, comma_split ], - [ :address, identity ], - ] - ], - [ - /(.*)/, - [ - [ :name, identity ], - ] - ] - ] - end - - newparam(:position) do - desc "Where to place the new entry" - validate do |value| - raise "Wrong position statement '#{value}'" unless value =~ /^(before|after)/ - end - end - - newproperty(:method) do - desc "The authentication method" - end - - newproperty(:options) do - desc "The hash of authentication options" - defaultto({}) - end - - autorequire(:file) do - self[:target] - end -end diff --git a/lib/puppet/type/puppet_auth.rb b/lib/puppet/type/puppet_auth.rb deleted file mode 100644 index 4c10227..0000000 --- a/lib/puppet/type/puppet_auth.rb +++ /dev/null @@ -1,105 +0,0 @@ -# Manages settings in Puppet's auth.conf file -# -# Copyright (c) 2012 Raphaël Pinson -# Licensed under the Apache License, Version 2.0 - -Puppet::Type.newtype(:puppet_auth) do - @doc = "Manages settings in Puppet's auth.conf." - - ensurable - - def munge_boolean(value) - case value - when true, "true", :true - :true - when false, "false", :false - :false - else - fail("munge_boolean only takes booleans") - end - end - - newparam(:name) do - desc "The name of the resource." - isnamevar - end - - newparam(:path) do - desc "The path for the auth rule." - end - - newparam(:path_regex, :boolean => true) do - desc "Whether the path is specified as a regex." - - newvalues(:true, :false) - - munge do |value| - @resource.munge_boolean(value) - end - end - - newparam(:ins_before) do - desc "Optional XPath expression to specify where to insert the auth rule. - -This parameter takes special values working as aliases: - -- `first allow`, mapping to `path[allow][1]`; -- `last allow`, mapping to `path[allow][last()]`; -- `first deny`, mapping to `path[count(allow)=0][1]`; -- `last deny`, mapping to path[count(allow)=0][last()]`" - end - - newparam(:ins_after) do - desc "Optional XPath expression to specify where to insert the auth rule. - -This parameter takes special values working as aliases: - -- `first allow`, mapping to `path[allow][1]`; -- `last allow`, mapping to `path[allow][last()]`; -- `first deny`, mapping to `path[count(allow)=0][1]`; -- `last deny`, mapping to path[count(allow)=0][last()]`" - end - - newproperty(:environments, :array_matching => :all) do - desc "The list of environments the rule applies to." - end - - newproperty(:methods, :array_matching => :all) do - desc "The list of methods the rule applies to. Possible values are: - -- find; -- search; -- save; -- destroy." - end - - newproperty(:allow, :array_matching => :all) do - desc "The list of hosts allowed for this rule, -specified by hostname or cername. Regexes are allowed, -as well as the special value `*`." - end - - newproperty(:allow_ip, :array_matching => :all) do - desc "The list of IPs allowed for this rule. -Requires Puppet 3.0.0 or greater." - end - - newproperty(:authenticated) do - desc "The type of authentication for the rule. Possible values are: - -- yes; -- no; -- on; -- off; -- any." - end - - newparam(:target) do - desc "The file in which to store the settings, defaults to - `/etc/puppet/auth.conf`." - end - - autorequire(:file) do - self[:target] - end -end diff --git a/lib/puppet/type/shellvar.rb b/lib/puppet/type/shellvar.rb deleted file mode 100644 index c29d190..0000000 --- a/lib/puppet/type/shellvar.rb +++ /dev/null @@ -1,178 +0,0 @@ -# Manages variables in simple shell scripts -# -# Copyright (c) 2012 Dominic Cleal -# Licensed under the Apache License, Version 2.0 - -Puppet::Type.newtype(:shellvar) do - @doc = "Manages variables in simple shell scripts." - - ensurable do - desc "Create or remove the shellvar entry" - defaultvalues - block if block_given? - - newvalue(:unset) do - current = self.retrieve - if current == :absent - provider.create - elsif !provider.is_unset? - provider.unset - end - end - - newvalue(:exported) do - current = self.retrieve - if current == :absent - provider.create - elsif !provider.is_exported? - provider.export - end - end - - def insync?(is) - return true if should == :unset and is == :present and provider.is_unset? - return true if should == :exported and is == :present and provider.is_exported? - return false if should == :present and provider.is_unset? - return false if should == :present and provider.is_exported? - super - end - - def sync - if should == :present and provider.is_unset? - provider.ununset - elsif should == :present and provider.is_exported? - provider.unexport - else - super - end - end - end - - newparam(:variable) do - desc "The name of the variable, e.g. OPTIONS" - isnamevar - end - - newproperty(:value, :array_matching => :all) do - desc "Value to change the variable to." - - munge do |v| - v.to_s - end - - def insync?(is) - if provider.resource[:array_append] - should_arr = Array(should) - - # Join and split to ensure all elements are parsed - is_str = is.is_a?(Array) ? is.join(' ') : is - is_arr = is_str.split(' ') - (should_arr - is_arr).empty? - else - case provider.array_type - when :string - is == Array(should.join(' ')) - when :array - is == should - end - end - end - - def sync - if provider.resource[:array_append] - # Merge the two arrays - is = @resource.property(:value).retrieve - - # Join and split to ensure all elements are parsed - is_str = is.is_a?(Array) ? is.join(' ') : is - is_arr = is_str.split(' ') - - provider.value = is_arr | Array(self.should) - else - # Use the should array - provider.value = self.should - end - end - end - - newparam(:quoted) do - desc "Quoting method to use, defaults to `auto`. - -* `auto` will quote only if necessary, leaving existing quotes as-is -* `double` and `single` will always quotes -* `none` will remove quotes, which may result in save failures" - - newvalues :auto, :double, :single, :none, :false, :true - - defaultto :auto - - munge do |v| - case v - when true, "true", :true - :auto - when false, "false", :false - :none - else - v.to_sym - end - end - end - - newparam(:array_type) do - desc "Type of array mapping to use, defaults to `auto`. - -* `auto` will detect the current type, and default to `string` -* `string` will render the array as a string and use space-separated values -* `array` will render the array as a shell array" - - newvalues :auto, :string, :array - - defaultto :auto - end - - newparam(:array_append) do - desc "Whether to add to existing array values or replace all values." - - newvalues :false, :true - - defaultto :false - - munge do |v| - case v - when true, "true", :true - true - when false, "false", :false - false - end - end - end - - newparam(:target) do - desc "The file in which to store the variable." - end - - newproperty(:comment) do - desc "Text to be stored in a comment immediately above the entry. It will be automatically prepended with the name of the variable in order for the provider to know whether it controls the comment or not." - end - - newparam(:uncomment) do - desc "Whether to remove commented value when found." - - newvalues :true, :false - - defaultto :false - - munge do |v| - case v - when true, "true", :true - :true - when false, "false", :false - :false - end - end - end - - autorequire(:file) do - self[:target] - end -end diff --git a/lib/puppet/type/sshd_config.rb b/lib/puppet/type/sshd_config.rb deleted file mode 100644 index 334db09..0000000 --- a/lib/puppet/type/sshd_config.rb +++ /dev/null @@ -1,64 +0,0 @@ -# Manages settings in OpenSSH's sshd_config file -# -# Copyright (c) 2012 Raphaël Pinson -# Licensed under the Apache License, Version 2.0 - -Puppet::Type.newtype(:sshd_config) do - @doc = "Manages settings in an OpenSSH sshd_config file. - -The resource name is used for the setting name, but if the `condition` is -given, then the name can be something else and the `key` given as the name -of the setting. - -Subsystem entries are not managed by this type. There is a specific `sshd_config_subsystem` type to manage these entries." - - ensurable - - newparam(:name) do - desc "The name of the setting, or a unique string if `condition` given." - isnamevar - end - - newparam(:key) do - desc "Overrides setting name to prevent resource conflicts if `condition` is -given." - end - - newproperty(:value, :array_matching => :all) do - desc "Value to change the setting to. The follow parameters take an array of values: - -- MACs; -- AcceptEnv; -- AllowGroups; -- AllowUsers; -- DenyGroups; -- DenyUsers. - -All other parameters take a string. When passing an array to other parameters, only the first value in the array will be considered." - end - - newparam(:target) do - desc "The file in which to store the settings, defaults to -`/etc/ssh/sshd_config`." - end - - newparam(:condition) do - desc "Match group condition for the entry, -in the format: - - sshd_config { 'PermitRootLogin': - value => 'without-password', - condition => 'Host example.net', - } - -The value can contain multiple conditions, concatenated together with -whitespace. This is used if the `Match` block has multiple criteria. - - condition => 'Host example.net User root' - " - end - - autorequire(:file) do - self[:target] - end -end diff --git a/lib/puppet/type/sshd_config_subsystem.rb b/lib/puppet/type/sshd_config_subsystem.rb deleted file mode 100644 index 91b03f0..0000000 --- a/lib/puppet/type/sshd_config_subsystem.rb +++ /dev/null @@ -1,28 +0,0 @@ -# Manages Subsystem settings in OpenSSH's sshd_config file -# -# Copyright (c) 2012 Raphaël Pinson -# Licensed under the Apache License, Version 2.0 - -Puppet::Type.newtype(:sshd_config_subsystem) do - @doc = "Manages Subsystem settings in an OpenSSH sshd_config file." - - ensurable - - newparam(:name) do - desc "The name of the subsystem to set." - isnamevar - end - - newproperty(:command) do - desc "The command to execute upon subsystem request." - end - - newparam(:target) do - desc "The file in which to store the settings, defaults to - `/etc/ssh/sshd_config`." - end - - autorequire(:file) do - self[:target] - end -end diff --git a/lib/puppet/type/sysctl.rb b/lib/puppet/type/sysctl.rb deleted file mode 100644 index 9d56df9..0000000 --- a/lib/puppet/type/sysctl.rb +++ /dev/null @@ -1,73 +0,0 @@ -# Manages entries in /etc/sysctl.conf -# -# Copyright (c) 2012 Dominic Cleal -# Licensed under the Apache License, Version 2.0 - -Puppet::Type.newtype(:sysctl) do - @doc = "Manages entries in /etc/sysctl.conf." - - ensurable - - newparam(:name) do - desc "The name of the setting, e.g. net.ipv4.ip_forward" - isnamevar - end - - module SysctlValueSync - def insync?(is) - if resource[:apply] == :true - @live_value = provider.live_value - equal(should, is) and equal(should, @live_value) - else - equal(should, is) - end - end - - def change_to_s(current, new) - if resource[:apply] == :true - if equal(current, new) - return "changed live value from '#{@live_value}' to '#{new}'" - elsif equal(@live_value, new) - return "changed configuration value from '#{current}' to '#{new}'" - else - return "changed configuration value from '#{current}' to '#{new}' and live value from '#{@live_value}' to '#{new}'" - end - else - return "changed configuration value from '#{current}' to '#{new}'" - end - end - - def equal(a, b) - a.gsub(/\s+/, ' ') == b.gsub(/\s+/, ' ') - end - end - - newproperty(:val) do - desc "An alias for 'value'. Maintains interface compatibility with the traditional ParsedFile sysctl provider. If both are set, 'value' will take precedence over 'val'." - include SysctlValueSync - end - - newproperty(:value) do - desc "Value to change the setting to. Settings with multiple values (such as net.ipv4.tcp_mem) are represented as a single whitespace separated string." - include SysctlValueSync - end - - newparam(:target) do - desc "The file in which to store the settings, defaults to - `/etc/sysctl.conf`." - end - - newproperty(:comment) do - desc "Text to be stored in a comment immediately above the entry. It will be automatically prepended with the name of the setting in order for the provider to know whether it controls the comment or not." - end - - newparam(:apply, :boolean => true) do - desc "Whether to apply the value using the sysctl command." - newvalues(:true, :false) - defaultto(true) - end - - autorequire(:file) do - self[:target] - end -end diff --git a/lib/puppet/type/syslog.rb b/lib/puppet/type/syslog.rb deleted file mode 100644 index 0c41cff..0000000 --- a/lib/puppet/type/syslog.rb +++ /dev/null @@ -1,66 +0,0 @@ -# Manages settings in syslog.conf file -# -# Copyright (c) 2012 Raphaël Pinson -# Licensed under the Apache License, Version 2.0 - -Puppet::Type.newtype(:syslog) do - @doc = "Manages settings in syslog.conf." - - ensurable - - def munge_boolean(value) - case value - when true, "true", :true - :true - when false, "false", :false - :false - else - fail("munge_boolean only takes booleans") - end - end - - newparam(:name) do - desc "The name of the resource." - isnamevar - end - - newparam(:facility) do - desc "The syslog facility for the selector." - end - - newparam(:level) do - desc "The syslog level for the selector." - end - - newparam(:action_type) do - desc "The type of action: file, hostname, user or program." - end - - newparam(:action) do - desc "The action for the entry." - end - - newproperty(:no_sync, :boolean => true) do - desc "Whether to omit syncing the file after every logging, ony when action_type is file." - - newvalue(:true) - newvalue(:false) - - munge do |value| - @resource.munge_boolean(value) - end - end - - newparam(:target) do - desc "The file in which to store the settings, defaults to - `/etc/syslog.conf`." - end - - newparam(:lens) do - desc "The augeas lens used to parse the file" - end - - autorequire(:file) do - self[:target] - end -end diff --git a/manifests/init.pp b/manifests/init.pp deleted file mode 100644 index 6157970..0000000 --- a/manifests/init.pp +++ /dev/null @@ -1,17 +0,0 @@ -# Class: augeasproviders -# -# This module manages augeasproviders -# -# Parameters: -# -# Actions: -# -# Requires: -# -# Sample Usage: -# -# [Remember: No empty lines between comments and class definition] -class augeasproviders { - - -} diff --git a/spec/fixtures/unit/puppet/provider/apache_directive/augeas/broken b/spec/fixtures/unit/puppet/provider/apache_directive/augeas/broken deleted file mode 100644 index d79e0af..0000000 --- a/spec/fixtures/unit/puppet/provider/apache_directive/augeas/broken +++ /dev/null @@ -1 +0,0 @@ -); -# you will save yourself a lot of trouble. -# -# Do NOT add a slash at the end of the directory path. -# -#ServerRoot "/etc/apache2" - -# -# The accept serialization lock file MUST BE STORED ON A LOCAL DISK. -# -LockFile ${APACHE_LOCK_DIR}/accept.lock - -# -# PidFile: The file in which the server should record its process -# identification number when it starts. -# This needs to be set in /etc/apache2/envvars -# -PidFile ${APACHE_PID_FILE} - -# -# Timeout: The number of seconds before receives and sends time out. -# -Timeout 300 - -# -# KeepAlive: Whether or not to allow persistent connections (more than -# one request per connection). Set to "Off" to deactivate. -# -KeepAlive On - -# -# MaxKeepAliveRequests: The maximum number of requests to allow -# during a persistent connection. Set to 0 to allow an unlimited amount. -# We recommend you leave this number high, for maximum performance. -# -MaxKeepAliveRequests 100 - -# -# KeepAliveTimeout: Number of seconds to wait for the next request from the -# same client on the same connection. -# -KeepAliveTimeout 5 - -## -## Server-Pool Size Regulation (MPM specific) -## - -# prefork MPM -# StartServers: number of server processes to start -# MinSpareServers: minimum number of server processes which are kept spare -# MaxSpareServers: maximum number of server processes which are kept spare -# MaxClients: maximum number of server processes allowed to start -# MaxRequestsPerChild: maximum number of requests a server process serves - - StartServers 5 - MinSpareServers 5 - MaxSpareServers 10 - MaxClients 150 - MaxRequestsPerChild 0 - - -# worker MPM -# StartServers: initial number of server processes to start -# MinSpareThreads: minimum number of worker threads which are kept spare -# MaxSpareThreads: maximum number of worker threads which are kept spare -# ThreadLimit: ThreadsPerChild can be changed to this maximum value during a -# graceful restart. ThreadLimit can only be changed by stopping -# and starting Apache. -# ThreadsPerChild: constant number of worker threads in each server process -# MaxClients: maximum number of simultaneous client connections -# MaxRequestsPerChild: maximum number of requests a server process serves - - StartServers 2 - MinSpareThreads 25 - MaxSpareThreads 75 - ThreadLimit 64 - ThreadsPerChild 25 - MaxClients 150 - MaxRequestsPerChild 0 - - -# event MPM -# StartServers: initial number of server processes to start -# MinSpareThreads: minimum number of worker threads which are kept spare -# MaxSpareThreads: maximum number of worker threads which are kept spare -# ThreadsPerChild: constant number of worker threads in each server process -# MaxClients: maximum number of simultaneous client connections -# MaxRequestsPerChild: maximum number of requests a server process serves - - StartServers 2 - MinSpareThreads 25 - MaxSpareThreads 75 - ThreadLimit 64 - ThreadsPerChild 25 - MaxClients 150 - MaxRequestsPerChild 0 - - -# These need to be set in /etc/apache2/envvars -User ${APACHE_RUN_USER} -Group ${APACHE_RUN_GROUP} - -# -# AccessFileName: The name of the file to look for in each directory -# for additional configuration directives. See also the AllowOverride -# directive. -# - -AccessFileName .htaccess - -# -# The following lines prevent .htaccess and .htpasswd files from being -# viewed by Web clients. -# - - Order allow,deny - Deny from all - Satisfy all - - -# -# DefaultType is the default MIME type the server will use for a document -# if it cannot otherwise determine one, such as from filename extensions. -# If your server contains mostly text or HTML documents, "text/plain" is -# a good value. If most of your content is binary, such as applications -# or images, you may want to use "application/octet-stream" instead to -# keep browsers from trying to display binary files as though they are -# text. -# -# It is also possible to omit any default MIME type and let the -# client's browser guess an appropriate action instead. Typically the -# browser will decide based on the file's extension then. In cases -# where no good assumption can be made, letting the default MIME type -# unset is suggested instead of forcing the browser to accept -# incorrect metadata. -# -DefaultType None - - -# -# HostnameLookups: Log the names of clients or just their IP addresses -# e.g., www.apache.org (on) or 204.62.129.132 (off). -# The default is off because it'd be overall better for the net if people -# had to knowingly turn this feature on, since enabling it means that -# each client request will result in AT LEAST one lookup request to the -# nameserver. -# -HostnameLookups Off - -# ErrorLog: The location of the error log file. -# If you do not specify an ErrorLog directive within a -# container, error messages relating to that virtual host will be -# logged here. If you *do* define an error logfile for a -# container, that host's errors will be logged there and not here. -# -ErrorLog ${APACHE_LOG_DIR}/error.log - -# -# LogLevel: Control the number of messages logged to the error_log. -# Possible values include: debug, info, notice, warn, error, crit, -# alert, emerg. -# -LogLevel warn - -# Include module configuration: -Include mods-enabled/*.load -Include mods-enabled/*.conf - -# Include all the user configurations: -Include httpd.conf - -# Include ports listing -Include ports.conf - -# -# The following directives define some format nicknames for use with -# a CustomLog directive (see below). -# If you are behind a reverse proxy, you might want to change %h into %{X-Forwarded-For}i -# -LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined -LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined -LogFormat "%h %l %u %t \"%r\" %>s %O" common -LogFormat "%{Referer}i -> %U" referer -LogFormat "%{User-agent}i" agent - -# Include of directories ignores editors' and dpkg's backup files, -# see README.Debian for details. - -# Include generic snippets of statements -Include conf.d/ - -# Include the virtual host configurations: -Include sites-enabled/ - -SetEnv TEST ignored -SetEnv TEST test -SetEnv TEST2 diff --git a/spec/fixtures/unit/puppet/provider/apache_directive/augeas/simple b/spec/fixtures/unit/puppet/provider/apache_directive/augeas/simple deleted file mode 100644 index 02b01d8..0000000 --- a/spec/fixtures/unit/puppet/provider/apache_directive/augeas/simple +++ /dev/null @@ -1,4 +0,0 @@ -SetEnv TEST -SetEnv FQDN ignored -SetEnv FQDN test.com -Example diff --git a/spec/fixtures/unit/puppet/provider/apache_setenv/augeas/broken b/spec/fixtures/unit/puppet/provider/apache_setenv/augeas/broken deleted file mode 100644 index d79e0af..0000000 --- a/spec/fixtures/unit/puppet/provider/apache_setenv/augeas/broken +++ /dev/null @@ -1 +0,0 @@ -); -# you will save yourself a lot of trouble. -# -# Do NOT add a slash at the end of the directory path. -# -#ServerRoot "/etc/apache2" - -# -# The accept serialization lock file MUST BE STORED ON A LOCAL DISK. -# -LockFile ${APACHE_LOCK_DIR}/accept.lock - -# -# PidFile: The file in which the server should record its process -# identification number when it starts. -# This needs to be set in /etc/apache2/envvars -# -PidFile ${APACHE_PID_FILE} - -# -# Timeout: The number of seconds before receives and sends time out. -# -Timeout 300 - -# -# KeepAlive: Whether or not to allow persistent connections (more than -# one request per connection). Set to "Off" to deactivate. -# -KeepAlive On - -# -# MaxKeepAliveRequests: The maximum number of requests to allow -# during a persistent connection. Set to 0 to allow an unlimited amount. -# We recommend you leave this number high, for maximum performance. -# -MaxKeepAliveRequests 100 - -# -# KeepAliveTimeout: Number of seconds to wait for the next request from the -# same client on the same connection. -# -KeepAliveTimeout 5 - -## -## Server-Pool Size Regulation (MPM specific) -## - -# prefork MPM -# StartServers: number of server processes to start -# MinSpareServers: minimum number of server processes which are kept spare -# MaxSpareServers: maximum number of server processes which are kept spare -# MaxClients: maximum number of server processes allowed to start -# MaxRequestsPerChild: maximum number of requests a server process serves - - StartServers 5 - MinSpareServers 5 - MaxSpareServers 10 - MaxClients 150 - MaxRequestsPerChild 0 - - -# worker MPM -# StartServers: initial number of server processes to start -# MinSpareThreads: minimum number of worker threads which are kept spare -# MaxSpareThreads: maximum number of worker threads which are kept spare -# ThreadLimit: ThreadsPerChild can be changed to this maximum value during a -# graceful restart. ThreadLimit can only be changed by stopping -# and starting Apache. -# ThreadsPerChild: constant number of worker threads in each server process -# MaxClients: maximum number of simultaneous client connections -# MaxRequestsPerChild: maximum number of requests a server process serves - - StartServers 2 - MinSpareThreads 25 - MaxSpareThreads 75 - ThreadLimit 64 - ThreadsPerChild 25 - MaxClients 150 - MaxRequestsPerChild 0 - - -# event MPM -# StartServers: initial number of server processes to start -# MinSpareThreads: minimum number of worker threads which are kept spare -# MaxSpareThreads: maximum number of worker threads which are kept spare -# ThreadsPerChild: constant number of worker threads in each server process -# MaxClients: maximum number of simultaneous client connections -# MaxRequestsPerChild: maximum number of requests a server process serves - - StartServers 2 - MinSpareThreads 25 - MaxSpareThreads 75 - ThreadLimit 64 - ThreadsPerChild 25 - MaxClients 150 - MaxRequestsPerChild 0 - - -# These need to be set in /etc/apache2/envvars -User ${APACHE_RUN_USER} -Group ${APACHE_RUN_GROUP} - -# -# AccessFileName: The name of the file to look for in each directory -# for additional configuration directives. See also the AllowOverride -# directive. -# - -AccessFileName .htaccess - -# -# The following lines prevent .htaccess and .htpasswd files from being -# viewed by Web clients. -# - - Order allow,deny - Deny from all - Satisfy all - - -# -# DefaultType is the default MIME type the server will use for a document -# if it cannot otherwise determine one, such as from filename extensions. -# If your server contains mostly text or HTML documents, "text/plain" is -# a good value. If most of your content is binary, such as applications -# or images, you may want to use "application/octet-stream" instead to -# keep browsers from trying to display binary files as though they are -# text. -# -# It is also possible to omit any default MIME type and let the -# client's browser guess an appropriate action instead. Typically the -# browser will decide based on the file's extension then. In cases -# where no good assumption can be made, letting the default MIME type -# unset is suggested instead of forcing the browser to accept -# incorrect metadata. -# -DefaultType None - - -# -# HostnameLookups: Log the names of clients or just their IP addresses -# e.g., www.apache.org (on) or 204.62.129.132 (off). -# The default is off because it'd be overall better for the net if people -# had to knowingly turn this feature on, since enabling it means that -# each client request will result in AT LEAST one lookup request to the -# nameserver. -# -HostnameLookups Off - -# ErrorLog: The location of the error log file. -# If you do not specify an ErrorLog directive within a -# container, error messages relating to that virtual host will be -# logged here. If you *do* define an error logfile for a -# container, that host's errors will be logged there and not here. -# -ErrorLog ${APACHE_LOG_DIR}/error.log - -# -# LogLevel: Control the number of messages logged to the error_log. -# Possible values include: debug, info, notice, warn, error, crit, -# alert, emerg. -# -LogLevel warn - -# Include module configuration: -Include mods-enabled/*.load -Include mods-enabled/*.conf - -# Include all the user configurations: -Include httpd.conf - -# Include ports listing -Include ports.conf - -# -# The following directives define some format nicknames for use with -# a CustomLog directive (see below). -# If you are behind a reverse proxy, you might want to change %h into %{X-Forwarded-For}i -# -LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined -LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined -LogFormat "%h %l %u %t \"%r\" %>s %O" common -LogFormat "%{Referer}i -> %U" referer -LogFormat "%{User-agent}i" agent - -# Include of directories ignores editors' and dpkg's backup files, -# see README.Debian for details. - -# Include generic snippets of statements -Include conf.d/ - -# Include the virtual host configurations: -Include sites-enabled/ - -SetEnv TEST ignored -SetEnv TEST test -SetEnv TEST2 diff --git a/spec/fixtures/unit/puppet/provider/apache_setenv/augeas/simple b/spec/fixtures/unit/puppet/provider/apache_setenv/augeas/simple deleted file mode 100644 index 02b01d8..0000000 --- a/spec/fixtures/unit/puppet/provider/apache_setenv/augeas/simple +++ /dev/null @@ -1,4 +0,0 @@ -SetEnv TEST -SetEnv FQDN ignored -SetEnv FQDN test.com -Example diff --git a/spec/fixtures/unit/puppet/provider/host/augeas/broken b/spec/fixtures/unit/puppet/provider/host/augeas/broken deleted file mode 100644 index 57f89ed..0000000 --- a/spec/fixtures/unit/puppet/provider/host/augeas/broken +++ /dev/null @@ -1 +0,0 @@ -broken diff --git a/spec/fixtures/unit/puppet/provider/host/augeas/empty b/spec/fixtures/unit/puppet/provider/host/augeas/empty deleted file mode 100644 index 8b13789..0000000 --- a/spec/fixtures/unit/puppet/provider/host/augeas/empty +++ /dev/null @@ -1 +0,0 @@ - diff --git a/spec/fixtures/unit/puppet/provider/host/augeas/full b/spec/fixtures/unit/puppet/provider/host/augeas/full deleted file mode 100644 index 2a4fb70..0000000 --- a/spec/fixtures/unit/puppet/provider/host/augeas/full +++ /dev/null @@ -1,4 +0,0 @@ -127.0.0.1 localhost.localdomain localhost -::1 localhost6.localdomain6 localhost6 -192.168.0.5 iridium iridium.example.com -192.168.0.10 argon # NAS diff --git a/spec/fixtures/unit/puppet/provider/kernel_parameter/grub/broken b/spec/fixtures/unit/puppet/provider/kernel_parameter/grub/broken deleted file mode 100644 index bf6d849..0000000 --- a/spec/fixtures/unit/puppet/provider/kernel_parameter/grub/broken +++ /dev/null @@ -1,26 +0,0 @@ -# grub.conf generated by anaconda -# -# Note that you do not have to rerun grub after making changes to this file -# NOTICE: You have a /boot partition. This means that -# all kernel and initrd paths are relative to /boot/, eg. -# root (hd0,0) -# kernel /vmlinuz-version ro root=/dev/VolGroup00/LogVol00 -# initrd /initrd-version.img -#boot=/dev/vda -{{{invalidentry}}} -default=0 -timeout=5 -splashimage=(hd0,0)/grub/splash.xpm.gz -hiddenmenu -title Red Hat Enterprise Linux Server (2.6.18-308.13.1.el5) - root (hd0,0) - kernel /vmlinuz-2.6.18-308.13.1.el5 ro root=/dev/VolGroup00/LogVol00 rhgb quiet elevator=noop divider=10 rd_LVM_LV=vg/lv1 rd_LVM_LV=vg/lv2 - initrd /initrd-2.6.18-308.13.1.el5.img -title Red Hat Enterprise Linux Server (2.6.18-308.13.1.el5) (recovery mode) - root (hd0,0) - kernel /vmlinuz-2.6.18-308.13.1.el5 ro root=/dev/VolGroup00/LogVol00 elevator=noop divider=10 S - initrd /initrd-2.6.18-308.13.1.el5.img -title Red Hat Enterprise Linux Server (2.6.18-194.el5) - root (hd0,0) - kernel /vmlinuz-2.6.18-194.el5 ro root=/dev/VolGroup00/LogVol00 rhgb quiet elevator=noop divider=10 - initrd /initrd-2.6.18-194.el5.img diff --git a/spec/fixtures/unit/puppet/provider/kernel_parameter/grub/full b/spec/fixtures/unit/puppet/provider/kernel_parameter/grub/full deleted file mode 100644 index 5ca5d66..0000000 --- a/spec/fixtures/unit/puppet/provider/kernel_parameter/grub/full +++ /dev/null @@ -1,25 +0,0 @@ -# grub.conf generated by anaconda -# -# Note that you do not have to rerun grub after making changes to this file -# NOTICE: You have a /boot partition. This means that -# all kernel and initrd paths are relative to /boot/, eg. -# root (hd0,0) -# kernel /vmlinuz-version ro root=/dev/VolGroup00/LogVol00 -# initrd /initrd-version.img -#boot=/dev/vda -default=0 -timeout=5 -splashimage=(hd0,0)/grub/splash.xpm.gz -hiddenmenu -title Red Hat Enterprise Linux Server (2.6.18-308.13.1.el5) - root (hd0,0) - kernel /vmlinuz-2.6.18-308.13.1.el5 ro root=/dev/VolGroup00/LogVol00 rhgb quiet elevator=noop divider=10 rd_LVM_LV=vg/lv1 rd_LVM_LV=vg/lv2 - initrd /initrd-2.6.18-308.13.1.el5.img -title Red Hat Enterprise Linux Server (2.6.18-308.13.1.el5) (recovery mode) - root (hd0,0) - kernel /vmlinuz-2.6.18-308.13.1.el5 ro root=/dev/VolGroup00/LogVol00 elevator=noop divider=10 S - initrd /initrd-2.6.18-308.13.1.el5.img -title Red Hat Enterprise Linux Server (2.6.18-194.el5) - root (hd0,0) - kernel /vmlinuz-2.6.18-194.el5 ro root=/dev/VolGroup00/LogVol00 rhgb quiet elevator=noop divider=10 - initrd /initrd-2.6.18-194.el5.img diff --git a/spec/fixtures/unit/puppet/provider/kernel_parameter/grub2/broken b/spec/fixtures/unit/puppet/provider/kernel_parameter/grub2/broken deleted file mode 100644 index 2d7980b..0000000 --- a/spec/fixtures/unit/puppet/provider/kernel_parameter/grub2/broken +++ /dev/null @@ -1,9 +0,0 @@ -GRUB_TIMEOUT = 5 -GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)" -GRUB_DEFAULT=saved -# GRUB_TERMINAL="serial console" -# GRUB_SERIAL_COMMAND="serial --unit=0 --speed=9600" -GRUB_CMDLINE_LINUX="quiet elevator=noop divider=10" -GRUB_CMDLINE_LINUX_DEFAULT="rhgb" -GRUB_DISABLE_RECOVERY="true" -GRUB_THEME=/boot/grub2/themes/system/theme.txt diff --git a/spec/fixtures/unit/puppet/provider/kernel_parameter/grub2/full b/spec/fixtures/unit/puppet/provider/kernel_parameter/grub2/full deleted file mode 100644 index 3f7a952..0000000 --- a/spec/fixtures/unit/puppet/provider/kernel_parameter/grub2/full +++ /dev/null @@ -1,9 +0,0 @@ -GRUB_TIMEOUT=5 -GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)" -GRUB_DEFAULT=saved -# GRUB_TERMINAL="serial console" -# GRUB_SERIAL_COMMAND="serial --unit=0 --speed=9600" -GRUB_CMDLINE_LINUX="quiet elevator=noop divider=10" -GRUB_CMDLINE_LINUX_DEFAULT="rhgb" -GRUB_DISABLE_RECOVERY="true" -GRUB_THEME=/boot/grub2/themes/system/theme.txt diff --git a/spec/fixtures/unit/puppet/provider/mailalias/augeas/broken b/spec/fixtures/unit/puppet/provider/mailalias/augeas/broken deleted file mode 100644 index 57f89ed..0000000 --- a/spec/fixtures/unit/puppet/provider/mailalias/augeas/broken +++ /dev/null @@ -1 +0,0 @@ -broken diff --git a/spec/fixtures/unit/puppet/provider/mailalias/augeas/empty b/spec/fixtures/unit/puppet/provider/mailalias/augeas/empty deleted file mode 100644 index e69de29..0000000 diff --git a/spec/fixtures/unit/puppet/provider/mailalias/augeas/full b/spec/fixtures/unit/puppet/provider/mailalias/augeas/full deleted file mode 100644 index ec1b478..0000000 --- a/spec/fixtures/unit/puppet/provider/mailalias/augeas/full +++ /dev/null @@ -1,4 +0,0 @@ -# Basic system aliases -- these MUST be present. -mailer-daemon: postmaster -postmaster: root -test: user1, user2 diff --git a/spec/fixtures/unit/puppet/provider/mailalias/augeas/fullquotes b/spec/fixtures/unit/puppet/provider/mailalias/augeas/fullquotes deleted file mode 100644 index 89581ae..0000000 --- a/spec/fixtures/unit/puppet/provider/mailalias/augeas/fullquotes +++ /dev/null @@ -1,5 +0,0 @@ -# Basic system aliases -- these MUST be present. -mailer-daemon: postmaster -postmaster: root -test: user1, user2 -users-leave: "| /var/lib/mailman/mail/mailman leave users" diff --git a/spec/fixtures/unit/puppet/provider/mounttab/fstab/broken b/spec/fixtures/unit/puppet/provider/mounttab/fstab/broken deleted file mode 100644 index 344a3d7..0000000 --- a/spec/fixtures/unit/puppet/provider/mounttab/fstab/broken +++ /dev/null @@ -1,17 +0,0 @@ -brokenfile -# -# /etc/fstab -# Created by anaconda on Mon Aug 16 11:08:41 2010 -# -# Accessible filesystems, by reference, are maintained under '/dev/disk' -# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info -# -/dev/mapper/vgiridium-lvroot / ext4 noatime 1 1 -UUID=23b3b5f4-d5b3-4661-ad41-caa970f3ca59 /boot ext4 noatime 1 2 -/dev/mapper/luks-10f63ee4-8296-434e-8de1-cde932e8a2e1 /home ext4 noatime 1 2 -tmpfs /tmp tmpfs size=1024m 0 0 -UUID=7ce78ba2-1bba-49f4-9790-bfb6b2010bb1 swap swap defaults 0 0 -tmpfs /dev/shm tmpfs defaults 0 0 -devpts /dev/pts devpts gid=5,mode=620 0 0 -sysfs /sys sysfs defaults 0 0 -proc /proc proc defaults 0 0 diff --git a/spec/fixtures/unit/puppet/provider/mounttab/fstab/empty b/spec/fixtures/unit/puppet/provider/mounttab/fstab/empty deleted file mode 100644 index e69de29..0000000 diff --git a/spec/fixtures/unit/puppet/provider/mounttab/fstab/full b/spec/fixtures/unit/puppet/provider/mounttab/fstab/full deleted file mode 100644 index 85381dd..0000000 --- a/spec/fixtures/unit/puppet/provider/mounttab/fstab/full +++ /dev/null @@ -1,16 +0,0 @@ - -# -# /etc/fstab -# Created by anaconda on Mon Aug 16 11:08:41 2010 -# -# Accessible filesystems, by reference, are maintained under '/dev/disk' -# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info -# -/dev/mapper/vgiridium-lvroot / ext4 noatime -UUID=23b3b5f4-d5b3-4661-ad41-caa970f3ca59 /boot ext4 noatime 1 2 -/dev/mapper/luks-10f63ee4-8296-434e-8de1-cde932e8a2e1 /home ext4 noatime 1 2 -tmpfs /tmp tmpfs size=1024m 0 0 -tmpfs /dev/shm tmpfs defaults 0 0 -devpts /dev/pts devpts gid=5,mode=620 0 0 -sysfs /sys sysfs defaults 0 0 -proc /proc proc defaults 0 0 diff --git a/spec/fixtures/unit/puppet/provider/mounttab/fstab/nooptions b/spec/fixtures/unit/puppet/provider/mounttab/fstab/nooptions deleted file mode 100644 index ce0c944..0000000 --- a/spec/fixtures/unit/puppet/provider/mounttab/fstab/nooptions +++ /dev/null @@ -1,17 +0,0 @@ - -# -# /etc/fstab -# Created by anaconda on Mon Aug 16 11:08:41 2010 -# -# Accessible filesystems, by reference, are maintained under '/dev/disk' -# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info -# -/dev/mapper/vgiridium-lvroot / ext4 noatime -UUID=23b3b5f4-d5b3-4661-ad41-caa970f3ca59 /boot ext4 noatime 1 2 -/dev/mapper/luks-10f63ee4-8296-434e-8de1-cde932e8a2e1 /home ext4 noatime 1 2 -tmpfs /tmp tmpfs size=1024m 0 0 -UUID=7ce78ba2-1bba-49f4-9790-bfb6b2010bb1 swap swap -tmpfs /dev/shm tmpfs defaults 0 0 -devpts /dev/pts devpts gid=5,mode=620 0 0 -sysfs /sys sysfs defaults 0 0 -proc /proc proc defaults 0 0 diff --git a/spec/fixtures/unit/puppet/provider/mounttab/vfstab/broken b/spec/fixtures/unit/puppet/provider/mounttab/vfstab/broken deleted file mode 100644 index 998235c..0000000 --- a/spec/fixtures/unit/puppet/provider/mounttab/vfstab/broken +++ /dev/null @@ -1,9 +0,0 @@ -brokenfile -#device device mount FS fsck mount mount -#to mount to fsck point type pass at boot options -# -fd - /dev/fd fd - no - -/proc - /proc proc - no - -/dev/dsk/c0t0d0s1 - - swap - no - -/dev/dsk/c0t0d0s0 /dev/rdsk/c0t0d0s0 / ufs 1 no - -swap - /tmp tmpfs - yes - diff --git a/spec/fixtures/unit/puppet/provider/mounttab/vfstab/empty b/spec/fixtures/unit/puppet/provider/mounttab/vfstab/empty deleted file mode 100644 index e69de29..0000000 diff --git a/spec/fixtures/unit/puppet/provider/mounttab/vfstab/full b/spec/fixtures/unit/puppet/provider/mounttab/vfstab/full deleted file mode 100644 index eaa5f86..0000000 --- a/spec/fixtures/unit/puppet/provider/mounttab/vfstab/full +++ /dev/null @@ -1,9 +0,0 @@ -#device device mount FS fsck mount mount -#to mount to fsck point type pass at boot options -# -fd - /dev/fd fd - no - -/proc - /proc proc - no - -/dev/dsk/c0t0d0s1 - - swap - no - -/dev/dsk/c0t0d0s0 /dev/rdsk/c0t0d0s0 / ufs 1 no - -mydev /dev/rdsk/c0t0d1s0 /fsck ufs 1 yes - -swap - /tmp tmpfs - yes size=1024m diff --git a/spec/fixtures/unit/puppet/provider/nrpe_command/augeas/broken b/spec/fixtures/unit/puppet/provider/nrpe_command/augeas/broken deleted file mode 100644 index 57f89ed..0000000 --- a/spec/fixtures/unit/puppet/provider/nrpe_command/augeas/broken +++ /dev/null @@ -1 +0,0 @@ -broken diff --git a/spec/fixtures/unit/puppet/provider/nrpe_command/augeas/empty b/spec/fixtures/unit/puppet/provider/nrpe_command/augeas/empty deleted file mode 100644 index e69de29..0000000 diff --git a/spec/fixtures/unit/puppet/provider/nrpe_command/augeas/full b/spec/fixtures/unit/puppet/provider/nrpe_command/augeas/full deleted file mode 100644 index 85c5325..0000000 --- a/spec/fixtures/unit/puppet/provider/nrpe_command/augeas/full +++ /dev/null @@ -1,226 +0,0 @@ -############################################################################# -# Sample NRPE Config File -# Written by: Ethan Galstad (nagios@nagios.org) -# -# Last Modified: 11-23-2007 -# -# NOTES: -# This is a sample configuration file for the NRPE daemon. It needs to be -# located on the remote host that is running the NRPE daemon, not the host -# from which the check_nrpe client is being executed. -############################################################################# - - -# LOG FACILITY -# The syslog facility that should be used for logging purposes. - -log_facility=foo'bar - - - -# PID FILE -# The name of the file in which the NRPE daemon should write it's process ID -# number. The file is only written if the NRPE daemon is started by the root -# user and is running in standalone mode. - -pid_file=/var/run/nagios/nrpe.pid - - - -# PORT NUMBER -# Port number we should wait for connections on. -# NOTE: This must be a non-priviledged port (i.e. > 1024). -# NOTE: This option is ignored if NRPE is running under either inetd or xinetd - -server_port=5666 - - - -# SERVER ADDRESS -# Address that nrpe should bind to in case there are more than one interface -# and you do not want nrpe to bind on all interfaces. -# NOTE: This option is ignored if NRPE is running under either inetd or xinetd - -#server_address=127.0.0.1 - - - -# NRPE USER -# This determines the effective user that the NRPE daemon should run as. -# You can either supply a username or a UID. -# -# NOTE: This option is ignored if NRPE is running under either inetd or xinetd - -nrpe_user=nagios - - - -# NRPE GROUP -# This determines the effective group that the NRPE daemon should run as. -# You can either supply a group name or a GID. -# -# NOTE: This option is ignored if NRPE is running under either inetd or xinetd - -nrpe_group=nagios - - - -# ALLOWED HOST ADDRESSES -# This is an optional comma-delimited list of IP address or hostnames -# that are allowed to talk to the NRPE daemon. -# -# Note: The daemon only does rudimentary checking of the client's IP -# address. I would highly recommend adding entries in your /etc/hosts.allow -# file to allow only the specified host to connect to the port -# you are running this daemon on. -# -# NOTE: This option is ignored if NRPE is running under either inetd or xinetd - -allowed_hosts=127.0.0.1 - - - -# COMMAND ARGUMENT PROCESSING -# This option determines whether or not the NRPE daemon will allow clients -# to specify arguments to commands that are executed. This option only works -# if the daemon was configured with the --enable-command-args configure script -# option. -# -# *** ENABLING THIS OPTION IS A SECURITY RISK! *** -# Read the SECURITY file for information on some of the security implications -# of enabling this variable. -# -# Values: 0=do not allow arguments, 1=allow command arguments - -dont_blame_nrpe=0 - - - -# COMMAND PREFIX -# This option allows you to prefix all commands with a user-defined string. -# A space is automatically added between the specified prefix string and the -# command line from the command definition. -# -# *** THIS EXAMPLE MAY POSE A POTENTIAL SECURITY RISK, SO USE WITH CAUTION! *** -# Usage scenario: -# Execute restricted commmands using sudo. For this to work, you need to add -# the nagios user to your /etc/sudoers. An example entry for alllowing -# execution of the plugins from might be: -# -# nagios ALL=(ALL) NOPASSWD: /usr/lib/nagios/plugins/ -# -# This lets the nagios user run all commands in that directory (and only them) -# without asking for a password. If you do this, make sure you don't give -# random users write access to that directory or its contents! - -# command_prefix=/usr/bin/sudo - - - -# DEBUGGING OPTION -# This option determines whether or not debugging messages are logged to the -# syslog facility. -# Values: 0=debugging off, 1=debugging on - -debug=0 - - - -# COMMAND TIMEOUT -# This specifies the maximum number of seconds that the NRPE daemon will -# allow plugins to finish executing before killing them off. - -command_timeout=60 - - - -# CONNECTION TIMEOUT -# This specifies the maximum number of seconds that the NRPE daemon will -# wait for a connection to be established before exiting. This is sometimes -# seen where a network problem stops the SSL being established even though -# all network sessions are connected. This causes the nrpe daemons to -# accumulate, eating system resources. Do not set this too low. - -connection_timeout=300 - - - -# WEEK RANDOM SEED OPTION -# This directive allows you to use SSL even if your system does not have -# a /dev/random or /dev/urandom (on purpose or because the necessary patches -# were not applied). The random number generator will be seeded from a file -# which is either a file pointed to by the environment valiable $RANDFILE -# or $HOME/.rnd. If neither exists, the pseudo random number generator will -# be initialized and a warning will be issued. -# Values: 0=only seed from /dev/[u]random, 1=also seed from weak randomness - -#allow_weak_random_seed=1 - - - -# INCLUDE CONFIG FILE -# This directive allows you to include definitions from an external config file. - -#include= - - - -# INCLUDE CONFIG DIRECTORY -# This directive allows you to include definitions from config files (with a -# .cfg extension) in one or more directories (with recursion). - -#include_dir= -#include_dir= - - - -# COMMAND DEFINITIONS -# Command definitions that this daemon will run. Definitions -# are in the following format: -# -# command[]= -# -# When the daemon receives a request to return the results of -# it will execute the command specified by the argument. -# -# Unlike Nagios, the command line cannot contain macros - it must be -# typed exactly as it should be executed. -# -# Note: Any plugins that are used in the command lines must reside -# on the machine that this daemon is running on! The examples below -# assume that you have plugins installed in a /usr/local/nagios/libexec -# directory. Also note that you will have to modify the definitions below -# to match the argument format the plugins expect. Remember, these are -# examples only! - - -# The following examples use hardcoded command arguments... - -command[check_users]=/usr/lib/nagios/plugins/check_users -w 5 -c 10 -command[check_load]=/usr/lib/nagios/plugins/check_load -w 15,10,5 -c 30,25,20 -command[check_hda1]=/usr/lib/nagios/plugins/check_disk -w 20% -c 10% -p /dev/hda1 -command[check_zombie_procs]=/usr/lib/nagios/plugins/check_procs -w 5 -c 10 -s Z -command[check_total_procs]=/usr/lib/nagios/plugins/check_procs -w 150 -c 200 -command[check_test]=/usr/lib/nagios/plugins/check_http -I 127.0.0.1 -p 8080 -u /ubrowse.action?acro=SCGC-ENS - -# The following examples allow user-supplied arguments and can -# only be used if the NRPE daemon was compiled with support for -# command arguments *AND* the dont_blame_nrpe directive in this -# config file is set to '1'. This poses a potential security risk, so -# make sure you read the SECURITY file before doing this. - -#command[check_users]=/usr/lib/nagios/plugins/check_users -w $ARG1$ -c $ARG2$ -#command[check_load]=/usr/lib/nagios/plugins/check_load -w $ARG1$ -c $ARG2$ -#command[check_disk]=/usr/lib/nagios/plugins/check_disk -w $ARG1$ -c $ARG2$ -p $ARG3$ -#command[check_procs]=/usr/lib/nagios/plugins/check_procs -w $ARG1$ -c $ARG2$ -s $ARG3$ - -# -# local configuration: -# if you'd prefer, you can instead place directives here -include=/etc/nagios/nrpe_local.cfg - -# -# you can place your config snipplets into nrpe.d/ -# only snipplets ending in .cfg will get included -include_dir=/etc/nagios/nrpe.d/ - diff --git a/spec/fixtures/unit/puppet/provider/pam/augeas/broken b/spec/fixtures/unit/puppet/provider/pam/augeas/broken deleted file mode 100644 index ddb41f8..0000000 --- a/spec/fixtures/unit/puppet/provider/pam/augeas/broken +++ /dev/null @@ -1,27 +0,0 @@ -#%PAM-1.0 -# This file is auto-generated. -# User changes will be destroyed the next time authconfig is run. -auth -auth sufficient pam_unix.so nullok try_first_pass -auth requisite pam_succeed_if.so uid >= 1000 quiet_success -auth sufficient pam_sss.so use_first_pass -auth required pam_deny.so - -account required pam_unix.so broken_shadow -account sufficient pam_localuser.so -account sufficient pam_succeed_if.so uid < 1000 quiet -account [default=bad success=ok user_unknown=ignore] pam_sss.so -account required pam_permit.so - -password requisite pam_pwquality.so try_first_pass retry=3 type= -password sufficient pam_unix.so sha512 shadow nullok try_first_pass use_authtok -password sufficient pam_sss.so use_authtok -password required pam_deny.so - -session optional pam_keyinit.so revoke -session required pam_limits.so --session optional pam_systemd.so -session optional pam_mkhomedir.so -session [success=1 default=ignore] pam_succeed_if.so service in crond quiet use_uid -session required pam_unix.so -session optional pam_sss.so diff --git a/spec/fixtures/unit/puppet/provider/pam/augeas/empty b/spec/fixtures/unit/puppet/provider/pam/augeas/empty deleted file mode 100644 index e69de29..0000000 diff --git a/spec/fixtures/unit/puppet/provider/pam/augeas/full b/spec/fixtures/unit/puppet/provider/pam/augeas/full deleted file mode 100644 index 1caaa5d..0000000 --- a/spec/fixtures/unit/puppet/provider/pam/augeas/full +++ /dev/null @@ -1,27 +0,0 @@ -#%PAM-1.0 -# This file is auto-generated. -# User changes will be destroyed the next time authconfig is run. -auth required pam_env.so -auth sufficient pam_unix.so nullok try_first_pass -auth requisite pam_succeed_if.so uid >= 1000 quiet_success -auth sufficient pam_sss.so use_first_pass -auth required pam_deny.so - -account required pam_unix.so broken_shadow -account sufficient pam_localuser.so -account sufficient pam_succeed_if.so uid < 1000 quiet -account [default=bad success=ok user_unknown=ignore] pam_sss.so -account required pam_permit.so - -password requisite pam_pwquality.so try_first_pass retry=3 type= -password sufficient pam_unix.so sha512 shadow nullok try_first_pass use_authtok -password sufficient pam_sss.so use_authtok -password required pam_deny.so - -session optional pam_keyinit.so revoke -session required pam_limits.so --session optional pam_systemd.so -session optional pam_mkhomedir.so -session [success=1 default=ignore] pam_succeed_if.so service in crond quiet use_uid -session required pam_unix.so -session optional pam_sss.so diff --git a/spec/fixtures/unit/puppet/provider/pg_hba/augeas/broken b/spec/fixtures/unit/puppet/provider/pg_hba/augeas/broken deleted file mode 100644 index 0be8e70..0000000 --- a/spec/fixtures/unit/puppet/provider/pg_hba/augeas/broken +++ /dev/null @@ -1,82 +0,0 @@ -# Allow any user on the local system to connect to any database with -# any database user name using Unix-domain sockets (the default for local -# connections). -# -# TYPE DATABASE USER ADDRESS METHOD -local all all trust - -# The same using local loopback TCP/IP connections. -# -# TYPE DATABASE USER ADDRESS METHOD - all all 127.0.0.1/32 trust - -# The same as the previous line, but using a separate netmask column -# -# TYPE DATABASE USER IP-ADDRESS IP-MASK METHOD -host all all 127.0.0.1 255.255.255.255 trust - -# The same over IPv6. -# -# TYPE DATABASE USER ADDRESS METHOD -host all all ::1/128 trust - -# The same using a host name (would typically cover both IPv4 and IPv6). -# -# TYPE DATABASE USER ADDRESS METHOD -host all all localhost trust - -# Allow any user from any host with IP address 192.168.93.x to connect -# to database "postgres" as the same user name that ident reports for -# the connection (typically the operating system user name). -# -# TYPE DATABASE USER ADDRESS METHOD -host postgres all 192.168.93.0/24 ident - -# Allow any user from host 192.168.12.10 to connect to database -# "postgres" if the user's password is correctly supplied. -# -# TYPE DATABASE USER ADDRESS METHOD -host postgres all 192.168.12.10/32 md5 - -# Allow any user from hosts in the example.com domain to connect to -# any database if the user's password is correctly supplied. -# -# TYPE DATABASE USER ADDRESS METHOD -host all all .example.com md5 - -# In the absence of preceding "host" lines, these two lines will -# reject all connections from 192.168.54.1 (since that entry will be -# matched first), but allow Kerberos 5 connections from anywhere else -# on the Internet. The zero mask causes no bits of the host IP -# address to be considered, so it matches any host. -# -# TYPE DATABASE USER ADDRESS METHOD -host all all 192.168.54.1/32 reject -host all all 0.0.0.0/0 krb5 - -# Allow users from 192.168.x.x hosts to connect to any database, if -# they pass the ident check. If, for example, ident says the user is -# "bryanh" and he requests to connect as PostgreSQL user "guest1", the -# connection is allowed if there is an entry in pg_ident.conf for map -# "omicron" that says "bryanh" is allowed to connect as "guest1". -# -# TYPE DATABASE USER ADDRESS METHOD -host all all 192.168.0.0/16 ident map=omicron - -# If these are the only three lines for local connections, they will -# allow local users to connect only to their own databases (databases -# with the same name as their database user name) except for administrators -# and members of role "support", who can connect to all databases. The file -# $PGDATA/admins contains a list of names of administrators. Passwords -# are required in all cases. -# -# TYPE DATABASE USER ADDRESS METHOD -local sameuser all md5 -local all @admins md5 -local all +support md5 - -# The last two lines above can be combined into a single line: -local all @admins,+support md5 - -# The database column can also use lists and file names: -local db1,db2,@demodbs all md5 diff --git a/spec/fixtures/unit/puppet/provider/pg_hba/augeas/empty b/spec/fixtures/unit/puppet/provider/pg_hba/augeas/empty deleted file mode 100644 index 8b13789..0000000 --- a/spec/fixtures/unit/puppet/provider/pg_hba/augeas/empty +++ /dev/null @@ -1 +0,0 @@ - diff --git a/spec/fixtures/unit/puppet/provider/pg_hba/augeas/full b/spec/fixtures/unit/puppet/provider/pg_hba/augeas/full deleted file mode 100644 index 9bb4455..0000000 --- a/spec/fixtures/unit/puppet/provider/pg_hba/augeas/full +++ /dev/null @@ -1,82 +0,0 @@ -# Allow any user on the local system to connect to any database with -# any database user name using Unix-domain sockets (the default for local -# connections). -# -# TYPE DATABASE USER ADDRESS METHOD -local all all trust - -# The same using local loopback TCP/IP connections. -# -# TYPE DATABASE USER ADDRESS METHOD -host all all 127.0.0.1/32 trust - -# The same as the previous line, but using a separate netmask column -# -# TYPE DATABASE USER IP-ADDRESS IP-MASK METHOD -host all all 127.0.0.1 255.255.255.255 trust - -# The same over IPv6. -# -# TYPE DATABASE USER ADDRESS METHOD -host all all ::1/128 trust - -# The same using a host name (would typically cover both IPv4 and IPv6). -# -# TYPE DATABASE USER ADDRESS METHOD -host all all localhost trust - -# Allow any user from any host with IP address 192.168.93.x to connect -# to database "postgres" as the same user name that ident reports for -# the connection (typically the operating system user name). -# -# TYPE DATABASE USER ADDRESS METHOD -host postgres all 192.168.93.0/24 ident - -# Allow any user from host 192.168.12.10 to connect to database -# "postgres" if the user's password is correctly supplied. -# -# TYPE DATABASE USER ADDRESS METHOD -host postgres all 192.168.12.10/32 md5 - -# Allow any user from hosts in the example.com domain to connect to -# any database if the user's password is correctly supplied. -# -# TYPE DATABASE USER ADDRESS METHOD -host all all .example.com md5 - -# In the absence of preceding "host" lines, these two lines will -# reject all connections from 192.168.54.1 (since that entry will be -# matched first), but allow Kerberos 5 connections from anywhere else -# on the Internet. The zero mask causes no bits of the host IP -# address to be considered, so it matches any host. -# -# TYPE DATABASE USER ADDRESS METHOD -host all all 192.168.54.1/32 reject -host all all 0.0.0.0/0 krb5 - -# Allow users from 192.168.x.x hosts to connect to any database, if -# they pass the ident check. If, for example, ident says the user is -# "bryanh" and he requests to connect as PostgreSQL user "guest1", the -# connection is allowed if there is an entry in pg_ident.conf for map -# "omicron" that says "bryanh" is allowed to connect as "guest1". -# -# TYPE DATABASE USER ADDRESS METHOD -host all all 192.168.0.0/16 ident map=omicron - -# If these are the only three lines for local connections, they will -# allow local users to connect only to their own databases (databases -# with the same name as their database user name) except for administrators -# and members of role "support", who can connect to all databases. The file -# $PGDATA/admins contains a list of names of administrators. Passwords -# are required in all cases. -# -# TYPE DATABASE USER ADDRESS METHOD -local sameuser all md5 -local all @admins md5 -local all +support md5 - -# The last two lines above can be combined into a single line: -local all @admins,+support md5 - -# The database column can also use lists and file names: -local db1,db2,@demodbs all md5 diff --git a/spec/fixtures/unit/puppet/provider/puppet_auth/augeas/broken b/spec/fixtures/unit/puppet/provider/puppet_auth/augeas/broken deleted file mode 100644 index 092bc2b..0000000 --- a/spec/fixtures/unit/puppet/provider/puppet_auth/augeas/broken +++ /dev/null @@ -1 +0,0 @@ -; diff --git a/spec/fixtures/unit/puppet/provider/puppet_auth/augeas/empty b/spec/fixtures/unit/puppet/provider/puppet_auth/augeas/empty deleted file mode 100644 index e69de29..0000000 diff --git a/spec/fixtures/unit/puppet/provider/puppet_auth/augeas/full b/spec/fixtures/unit/puppet/provider/puppet_auth/augeas/full deleted file mode 100644 index 24af848..0000000 --- a/spec/fixtures/unit/puppet/provider/puppet_auth/augeas/full +++ /dev/null @@ -1,53 +0,0 @@ -### Authenticated ACL - those applies only when the client -### has a valid certificate and is thus authenticated - -# allow nodes to retrieve their own catalog (ie their configuration) -path ~ ^/catalog/([^/]+)$ -method find -allow $1 - -# allow nodes to retrieve their own node definition -path ~ ^/node/([^/]+)$ -method find -allow $1 - -# allow all nodes to access the certificates services -path /certificate_revocation_list/ca -method find -allow * - -# allow all nodes to store their reports -path /report -method save -allow * - -# inconditionnally allow access to all files services -# which means in practice that fileserver.conf will -# still be used -path /file -allow * - -### Unauthenticated ACL, for clients for which the current master doesn't -### have a valid certificate; we allow authenticated users, too, because -### there isn't a great harm in letting that request through. - -# allow access to the master CA -path /certificate/ca -auth any -method find -allow * - -path /certificate/ -auth any -method find -allow * - -path /certificate_request -auth any -method find, save -allow * - -# this one is not stricly necessary, but it has the merit -# to show the default policy which is deny everything else -path / -auth any diff --git a/spec/fixtures/unit/puppet/provider/shellvar/augeas/broken b/spec/fixtures/unit/puppet/provider/shellvar/augeas/broken deleted file mode 100644 index 70d9e5f..0000000 --- a/spec/fixtures/unit/puppet/provider/shellvar/augeas/broken +++ /dev/null @@ -1,8 +0,0 @@ -# Options for ntpdate -OPTIONS = "-p 2" - -# Number of retries before giving up -RETRIES=2 - -# Set to 'yes' to sync hw clock after successful ntpdate -SYNC_HWCLOCK=no diff --git a/spec/fixtures/unit/puppet/provider/shellvar/augeas/empty b/spec/fixtures/unit/puppet/provider/shellvar/augeas/empty deleted file mode 100644 index e69de29..0000000 diff --git a/spec/fixtures/unit/puppet/provider/shellvar/augeas/full b/spec/fixtures/unit/puppet/provider/shellvar/augeas/full deleted file mode 100644 index 900bb98..0000000 --- a/spec/fixtures/unit/puppet/provider/shellvar/augeas/full +++ /dev/null @@ -1,18 +0,0 @@ -# Options for ntpdate -OPTIONS="-p 2" -OPTIONS_SINGLE='-p 2' - -# retry setting -# RETRIES: Number of retries before giving up -RETRIES=2 - -# Set to 'yes' to sync hw clock after successful ntpdate -#SYNC_HWCLOCK=no - -EXAMPLE=foo - -unset EXAMPLE_U -export EXAMPLE_E=baz - -STR_LIST="foo bar baz" -LST_LIST=(foo "bar baz" 123) diff --git a/spec/fixtures/unit/puppet/provider/sshd_config/augeas/broken b/spec/fixtures/unit/puppet/provider/sshd_config/augeas/broken deleted file mode 100644 index 6feb015..0000000 --- a/spec/fixtures/unit/puppet/provider/sshd_config/augeas/broken +++ /dev/null @@ -1,138 +0,0 @@ -# $OpenBSD: sshd_config,v 1.81 2009/10/08 14:03:41 markus Exp $ -;broken file -# This is the sshd server system-wide configuration file. See -# sshd_config(5) for more information. - -# This sshd was compiled with PATH=/usr/local/bin:/bin:/usr/bin - -# The strategy used for options in the default sshd_config shipped with -# OpenSSH is to specify options with their default value where -# possible, but leave them commented. Uncommented options change a -# default value. - -#Port 22 -#AddressFamily any -#ListenAddress 0.0.0.0 -#ListenAddress :: - -# The default requires explicit activation of protocol 1 -#Protocol 2 - -# HostKey for protocol version 1 -#HostKey /etc/ssh/ssh_host_key -# HostKeys for protocol version 2 -#HostKey /etc/ssh/ssh_host_rsa_key -#HostKey /etc/ssh/ssh_host_dsa_key - -# Lifetime and size of ephemeral version 1 server key -#KeyRegenerationInterval 1h -#ServerKeyBits 1024 - -# Logging -# obsoletes QuietMode and FascistLogging -#SyslogFacility AUTH -SyslogFacility AUTHPRIV -#LogLevel INFO - -# Authentication: - -AllowGroups sshusers - -#LoginGraceTime 2m -PermitRootLogin without-password -#StrictModes yes -#MaxAuthTries 6 -#MaxSessions 10 - -#RSAAuthentication yes -#PubkeyAuthentication yes -#AuthorizedKeysFile .ssh/authorized_keys -#AuthorizedKeysCommand none -#AuthorizedKeysCommandRunAs nobody - -# For this to work you will also need host keys in /etc/ssh/ssh_known_hosts -#RhostsRSAAuthentication no -# similar for protocol version 2 -#HostbasedAuthentication no -# Change to yes if you don't trust ~/.ssh/known_hosts for -# RhostsRSAAuthentication and HostbasedAuthentication -#IgnoreUserKnownHosts no -# Don't read the user's ~/.rhosts and ~/.shosts files -#IgnoreRhosts yes - -# To disable tunneled clear text passwords, change to no here! -#PasswordAuthentication yes -#PermitEmptyPasswords no -PasswordAuthentication yes - -# Change to no to disable s/key passwords -#ChallengeResponseAuthentication yes -ChallengeResponseAuthentication no - -# Kerberos options -#KerberosAuthentication no -#KerberosOrLocalPasswd yes -#KerberosTicketCleanup yes -#KerberosGetAFSToken no -#KerberosUseKuserok yes - -# GSSAPI options -#GSSAPIAuthentication no -GSSAPIAuthentication yes -#GSSAPICleanupCredentials yes -GSSAPICleanupCredentials yes -#GSSAPIStrictAcceptorCheck yes -#GSSAPIKeyExchange no - -# Set this to 'yes' to enable PAM authentication, account processing, -# and session processing. If this is enabled, PAM authentication will -# be allowed through the ChallengeResponseAuthentication and -# PasswordAuthentication. Depending on your PAM configuration, -# PAM authentication via ChallengeResponseAuthentication may bypass -# the setting of "PermitRootLogin without-password". -# If you just want the PAM account and session checks to run without -# PAM authentication, then enable this but set PasswordAuthentication -# and ChallengeResponseAuthentication to 'no'. -#UsePAM no -UsePAM yes - -# Accept locale-related environment variables -AcceptEnv LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES -AcceptEnv LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT -AcceptEnv LC_IDENTIFICATION LC_ALL LANGUAGE -AcceptEnv XMODIFIERS - -#AllowAgentForwarding yes -#AllowTcpForwarding yes -#GatewayPorts no -#X11Forwarding no -X11Forwarding yes -#X11DisplayOffset 10 -#X11UseLocalhost yes -#PrintMotd yes -#PrintLastLog yes -#TCPKeepAlive yes -#UseLogin no -#UsePrivilegeSeparation yes -#PermitUserEnvironment no -#Compression delayed -#ClientAliveInterval 0 -#ClientAliveCountMax 3 -#ShowPatchLevel no -#UseDNS yes -#PidFile /var/run/sshd.pid -#MaxStartups 10 -#PermitTunnel no -#ChrootDirectory none - -# no default banner path -#Banner none - -# override default of no subsystems -Subsystem sftp /usr/libexec/openssh/sftp-server - -# Example of overriding settings on a per-user basis -#Match User anoncvs -# X11Forwarding no -# AllowTcpForwarding no -# ForceCommand cvs server diff --git a/spec/fixtures/unit/puppet/provider/sshd_config/augeas/empty b/spec/fixtures/unit/puppet/provider/sshd_config/augeas/empty deleted file mode 100644 index e69de29..0000000 diff --git a/spec/fixtures/unit/puppet/provider/sshd_config/augeas/full b/spec/fixtures/unit/puppet/provider/sshd_config/augeas/full deleted file mode 100644 index 3f5c660..0000000 --- a/spec/fixtures/unit/puppet/provider/sshd_config/augeas/full +++ /dev/null @@ -1,141 +0,0 @@ -# $OpenBSD: sshd_config,v 1.81 2009/10/08 14:03:41 markus Exp $ - -# This is the sshd server system-wide configuration file. See -# sshd_config(5) for more information. - -# This sshd was compiled with PATH=/usr/local/bin:/bin:/usr/bin - -# The strategy used for options in the default sshd_config shipped with -# OpenSSH is to specify options with their default value where -# possible, but leave them commented. Uncommented options change a -# default value. - -#AddressFamily any -ListenAddress 0.0.0.0 -ListenAddress :: - -# The default requires explicit activation of protocol 1 -#Protocol 2 - -# HostKey for protocol version 1 -#HostKey /etc/ssh/ssh_host_key -# HostKeys for protocol version 2 -#HostKey /etc/ssh/ssh_host_rsa_key -#HostKey /etc/ssh/ssh_host_dsa_key - -# Lifetime and size of ephemeral version 1 server key -#KeyRegenerationInterval 1h -#ServerKeyBits 1024 - -# Logging -# obsoletes QuietMode and FascistLogging -#SyslogFacility AUTH -SyslogFacility AUTHPRIV -#LogLevel INFO - -# Authentication: - -AllowGroups sshusers admins - -#LoginGraceTime 2m -PermitRootLogin without-password -#StrictModes yes -#MaxAuthTries 6 -#MaxSessions 10 - -#RSAAuthentication yes -#PubkeyAuthentication yes -#AuthorizedKeysFile .ssh/authorized_keys -#AuthorizedKeysCommand none -#AuthorizedKeysCommandRunAs nobody - -# For this to work you will also need host keys in /etc/ssh/ssh_known_hosts -#RhostsRSAAuthentication no -# similar for protocol version 2 -#HostbasedAuthentication no -# Change to yes if you don't trust ~/.ssh/known_hosts for -# RhostsRSAAuthentication and HostbasedAuthentication -#IgnoreUserKnownHosts no -# Don't read the user's ~/.rhosts and ~/.shosts files -#IgnoreRhosts yes - -# To disable tunneled clear text passwords, change to no here! -#PasswordAuthentication yes -#PermitEmptyPasswords no -PasswordAuthentication yes - -# Change to no to disable s/key passwords -#ChallengeResponseAuthentication yes -ChallengeResponseAuthentication no - -# Kerberos options -#KerberosAuthentication no -#KerberosOrLocalPasswd yes -#KerberosTicketCleanup yes -#KerberosGetAFSToken no -#KerberosUseKuserok yes - -# GSSAPI options -#GSSAPIAuthentication no -GSSAPIAuthentication yes -#GSSAPICleanupCredentials yes -GSSAPICleanupCredentials yes -#GSSAPIStrictAcceptorCheck yes -#GSSAPIKeyExchange no - -# Set this to 'yes' to enable PAM authentication, account processing, -# and session processing. If this is enabled, PAM authentication will -# be allowed through the ChallengeResponseAuthentication and -# PasswordAuthentication. Depending on your PAM configuration, -# PAM authentication via ChallengeResponseAuthentication may bypass -# the setting of "PermitRootLogin without-password". -# If you just want the PAM account and session checks to run without -# PAM authentication, then enable this but set PasswordAuthentication -# and ChallengeResponseAuthentication to 'no'. -#UsePAM no -UsePAM yes - -# Accept locale-related environment variables -AcceptEnv LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES -AcceptEnv LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT -AcceptEnv LC_IDENTIFICATION LC_ALL LANGUAGE -AcceptEnv XMODIFIERS - -#AllowAgentForwarding yes -#AllowTcpForwarding yes -#GatewayPorts no -#X11Forwarding no -X11Forwarding yes -#X11DisplayOffset 10 -#X11UseLocalhost yes -#PrintMotd yes -#PrintLastLog yes -#TCPKeepAlive yes -#UseLogin no -#UsePrivilegeSeparation yes -#PermitUserEnvironment no -#Compression delayed -#ClientAliveInterval 0 -#ClientAliveCountMax 3 -#ShowPatchLevel no -#UseDNS yes -#PidFile /var/run/sshd.pid -#MaxStartups 10 -#PermitTunnel no -#ChrootDirectory none - -# no default banner path -#Banner none - -# override default of no subsystems -Subsystem sftp /usr/libexec/openssh/sftp-server - -# Example of overriding settings on a per-user basis -Match User anoncvs - X11Forwarding no - AllowTcpForwarding no - ForceCommand cvs server - -Match Host *.example.net User * - AllowAgentForwarding no - ListenAddress 10.1.1.2 diff --git a/spec/fixtures/unit/puppet/provider/sshd_config/augeas/nomatch b/spec/fixtures/unit/puppet/provider/sshd_config/augeas/nomatch deleted file mode 100644 index f9fcb05..0000000 --- a/spec/fixtures/unit/puppet/provider/sshd_config/augeas/nomatch +++ /dev/null @@ -1,131 +0,0 @@ -# $OpenBSD: sshd_config,v 1.81 2009/10/08 14:03:41 markus Exp $ - -# This is the sshd server system-wide configuration file. See -# sshd_config(5) for more information. - -# This sshd was compiled with PATH=/usr/local/bin:/bin:/usr/bin - -# The strategy used for options in the default sshd_config shipped with -# OpenSSH is to specify options with their default value where -# possible, but leave them commented. Uncommented options change a -# default value. - -#AddressFamily any -ListenAddress 0.0.0.0 -ListenAddress :: - -# The default requires explicit activation of protocol 1 -#Protocol 2 - -# HostKey for protocol version 1 -#HostKey /etc/ssh/ssh_host_key -# HostKeys for protocol version 2 -#HostKey /etc/ssh/ssh_host_rsa_key -#HostKey /etc/ssh/ssh_host_dsa_key - -# Lifetime and size of ephemeral version 1 server key -#KeyRegenerationInterval 1h -#ServerKeyBits 1024 - -# Logging -# obsoletes QuietMode and FascistLogging -#SyslogFacility AUTH -SyslogFacility AUTHPRIV -#LogLevel INFO - -# Authentication: - -AllowGroups sshusers admins - -#LoginGraceTime 2m -PermitRootLogin without-password -#StrictModes yes -#MaxAuthTries 6 -#MaxSessions 10 - -#RSAAuthentication yes -#PubkeyAuthentication yes -#AuthorizedKeysFile .ssh/authorized_keys -#AuthorizedKeysCommand none -#AuthorizedKeysCommandRunAs nobody - -# For this to work you will also need host keys in /etc/ssh/ssh_known_hosts -#RhostsRSAAuthentication no -# similar for protocol version 2 -#HostbasedAuthentication no -# Change to yes if you don't trust ~/.ssh/known_hosts for -# RhostsRSAAuthentication and HostbasedAuthentication -#IgnoreUserKnownHosts no -# Don't read the user's ~/.rhosts and ~/.shosts files -#IgnoreRhosts yes - -# To disable tunneled clear text passwords, change to no here! -#PasswordAuthentication yes -#PermitEmptyPasswords no -PasswordAuthentication yes - -# Change to no to disable s/key passwords -#ChallengeResponseAuthentication yes -ChallengeResponseAuthentication no - -# Kerberos options -#KerberosAuthentication no -#KerberosOrLocalPasswd yes -#KerberosTicketCleanup yes -#KerberosGetAFSToken no -#KerberosUseKuserok yes - -# GSSAPI options -#GSSAPIAuthentication no -GSSAPIAuthentication yes -#GSSAPICleanupCredentials yes -GSSAPICleanupCredentials yes -#GSSAPIStrictAcceptorCheck yes -#GSSAPIKeyExchange no - -# Set this to 'yes' to enable PAM authentication, account processing, -# and session processing. If this is enabled, PAM authentication will -# be allowed through the ChallengeResponseAuthentication and -# PasswordAuthentication. Depending on your PAM configuration, -# PAM authentication via ChallengeResponseAuthentication may bypass -# the setting of "PermitRootLogin without-password". -# If you just want the PAM account and session checks to run without -# PAM authentication, then enable this but set PasswordAuthentication -# and ChallengeResponseAuthentication to 'no'. -#UsePAM no -UsePAM yes - -# Accept locale-related environment variables -AcceptEnv LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES -AcceptEnv LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT -AcceptEnv LC_IDENTIFICATION LC_ALL LANGUAGE -AcceptEnv XMODIFIERS - -#AllowAgentForwarding yes -#AllowTcpForwarding yes -#GatewayPorts no -#X11Forwarding no -X11Forwarding yes -#X11DisplayOffset 10 -#X11UseLocalhost yes -#PrintMotd yes -#PrintLastLog yes -#TCPKeepAlive yes -#UseLogin no -#UsePrivilegeSeparation yes -#PermitUserEnvironment no -#Compression delayed -#ClientAliveInterval 0 -#ClientAliveCountMax 3 -#ShowPatchLevel no -#UseDNS yes -#PidFile /var/run/sshd.pid -#MaxStartups 10 -#PermitTunnel no -#ChrootDirectory none - -# no default banner path -#Banner none - -# override default of no subsystems -Subsystem sftp /usr/libexec/openssh/sftp-server diff --git a/spec/fixtures/unit/puppet/provider/sshd_config_subsystem/augeas/broken b/spec/fixtures/unit/puppet/provider/sshd_config_subsystem/augeas/broken deleted file mode 100644 index 6feb015..0000000 --- a/spec/fixtures/unit/puppet/provider/sshd_config_subsystem/augeas/broken +++ /dev/null @@ -1,138 +0,0 @@ -# $OpenBSD: sshd_config,v 1.81 2009/10/08 14:03:41 markus Exp $ -;broken file -# This is the sshd server system-wide configuration file. See -# sshd_config(5) for more information. - -# This sshd was compiled with PATH=/usr/local/bin:/bin:/usr/bin - -# The strategy used for options in the default sshd_config shipped with -# OpenSSH is to specify options with their default value where -# possible, but leave them commented. Uncommented options change a -# default value. - -#Port 22 -#AddressFamily any -#ListenAddress 0.0.0.0 -#ListenAddress :: - -# The default requires explicit activation of protocol 1 -#Protocol 2 - -# HostKey for protocol version 1 -#HostKey /etc/ssh/ssh_host_key -# HostKeys for protocol version 2 -#HostKey /etc/ssh/ssh_host_rsa_key -#HostKey /etc/ssh/ssh_host_dsa_key - -# Lifetime and size of ephemeral version 1 server key -#KeyRegenerationInterval 1h -#ServerKeyBits 1024 - -# Logging -# obsoletes QuietMode and FascistLogging -#SyslogFacility AUTH -SyslogFacility AUTHPRIV -#LogLevel INFO - -# Authentication: - -AllowGroups sshusers - -#LoginGraceTime 2m -PermitRootLogin without-password -#StrictModes yes -#MaxAuthTries 6 -#MaxSessions 10 - -#RSAAuthentication yes -#PubkeyAuthentication yes -#AuthorizedKeysFile .ssh/authorized_keys -#AuthorizedKeysCommand none -#AuthorizedKeysCommandRunAs nobody - -# For this to work you will also need host keys in /etc/ssh/ssh_known_hosts -#RhostsRSAAuthentication no -# similar for protocol version 2 -#HostbasedAuthentication no -# Change to yes if you don't trust ~/.ssh/known_hosts for -# RhostsRSAAuthentication and HostbasedAuthentication -#IgnoreUserKnownHosts no -# Don't read the user's ~/.rhosts and ~/.shosts files -#IgnoreRhosts yes - -# To disable tunneled clear text passwords, change to no here! -#PasswordAuthentication yes -#PermitEmptyPasswords no -PasswordAuthentication yes - -# Change to no to disable s/key passwords -#ChallengeResponseAuthentication yes -ChallengeResponseAuthentication no - -# Kerberos options -#KerberosAuthentication no -#KerberosOrLocalPasswd yes -#KerberosTicketCleanup yes -#KerberosGetAFSToken no -#KerberosUseKuserok yes - -# GSSAPI options -#GSSAPIAuthentication no -GSSAPIAuthentication yes -#GSSAPICleanupCredentials yes -GSSAPICleanupCredentials yes -#GSSAPIStrictAcceptorCheck yes -#GSSAPIKeyExchange no - -# Set this to 'yes' to enable PAM authentication, account processing, -# and session processing. If this is enabled, PAM authentication will -# be allowed through the ChallengeResponseAuthentication and -# PasswordAuthentication. Depending on your PAM configuration, -# PAM authentication via ChallengeResponseAuthentication may bypass -# the setting of "PermitRootLogin without-password". -# If you just want the PAM account and session checks to run without -# PAM authentication, then enable this but set PasswordAuthentication -# and ChallengeResponseAuthentication to 'no'. -#UsePAM no -UsePAM yes - -# Accept locale-related environment variables -AcceptEnv LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES -AcceptEnv LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT -AcceptEnv LC_IDENTIFICATION LC_ALL LANGUAGE -AcceptEnv XMODIFIERS - -#AllowAgentForwarding yes -#AllowTcpForwarding yes -#GatewayPorts no -#X11Forwarding no -X11Forwarding yes -#X11DisplayOffset 10 -#X11UseLocalhost yes -#PrintMotd yes -#PrintLastLog yes -#TCPKeepAlive yes -#UseLogin no -#UsePrivilegeSeparation yes -#PermitUserEnvironment no -#Compression delayed -#ClientAliveInterval 0 -#ClientAliveCountMax 3 -#ShowPatchLevel no -#UseDNS yes -#PidFile /var/run/sshd.pid -#MaxStartups 10 -#PermitTunnel no -#ChrootDirectory none - -# no default banner path -#Banner none - -# override default of no subsystems -Subsystem sftp /usr/libexec/openssh/sftp-server - -# Example of overriding settings on a per-user basis -#Match User anoncvs -# X11Forwarding no -# AllowTcpForwarding no -# ForceCommand cvs server diff --git a/spec/fixtures/unit/puppet/provider/sshd_config_subsystem/augeas/empty b/spec/fixtures/unit/puppet/provider/sshd_config_subsystem/augeas/empty deleted file mode 100644 index e69de29..0000000 diff --git a/spec/fixtures/unit/puppet/provider/sshd_config_subsystem/augeas/full b/spec/fixtures/unit/puppet/provider/sshd_config_subsystem/augeas/full deleted file mode 100644 index 92a1a79..0000000 --- a/spec/fixtures/unit/puppet/provider/sshd_config_subsystem/augeas/full +++ /dev/null @@ -1,141 +0,0 @@ -# $OpenBSD: sshd_config,v 1.81 2009/10/08 14:03:41 markus Exp $ - -# This is the sshd server system-wide configuration file. See -# sshd_config(5) for more information. - -# This sshd was compiled with PATH=/usr/local/bin:/bin:/usr/bin - -# The strategy used for options in the default sshd_config shipped with -# OpenSSH is to specify options with their default value where -# possible, but leave them commented. Uncommented options change a -# default value. - -#Port 22 -#AddressFamily any -#ListenAddress 0.0.0.0 -#ListenAddress :: - -# The default requires explicit activation of protocol 1 -#Protocol 2 - -# HostKey for protocol version 1 -#HostKey /etc/ssh/ssh_host_key -# HostKeys for protocol version 2 -#HostKey /etc/ssh/ssh_host_rsa_key -#HostKey /etc/ssh/ssh_host_dsa_key - -# Lifetime and size of ephemeral version 1 server key -#KeyRegenerationInterval 1h -#ServerKeyBits 1024 - -# Logging -# obsoletes QuietMode and FascistLogging -#SyslogFacility AUTH -SyslogFacility AUTHPRIV -#LogLevel INFO - -# Authentication: - -AllowGroups sshusers admins - -#LoginGraceTime 2m -PermitRootLogin without-password -#StrictModes yes -#MaxAuthTries 6 -#MaxSessions 10 - -#RSAAuthentication yes -#PubkeyAuthentication yes -#AuthorizedKeysFile .ssh/authorized_keys -#AuthorizedKeysCommand none -#AuthorizedKeysCommandRunAs nobody - -# For this to work you will also need host keys in /etc/ssh/ssh_known_hosts -#RhostsRSAAuthentication no -# similar for protocol version 2 -#HostbasedAuthentication no -# Change to yes if you don't trust ~/.ssh/known_hosts for -# RhostsRSAAuthentication and HostbasedAuthentication -#IgnoreUserKnownHosts no -# Don't read the user's ~/.rhosts and ~/.shosts files -#IgnoreRhosts yes - -# To disable tunneled clear text passwords, change to no here! -#PasswordAuthentication yes -#PermitEmptyPasswords no -PasswordAuthentication yes - -# Change to no to disable s/key passwords -#ChallengeResponseAuthentication yes -ChallengeResponseAuthentication no - -# Kerberos options -#KerberosAuthentication no -#KerberosOrLocalPasswd yes -#KerberosTicketCleanup yes -#KerberosGetAFSToken no -#KerberosUseKuserok yes - -# GSSAPI options -#GSSAPIAuthentication no -GSSAPIAuthentication yes -#GSSAPICleanupCredentials yes -GSSAPICleanupCredentials yes -#GSSAPIStrictAcceptorCheck yes -#GSSAPIKeyExchange no - -# Set this to 'yes' to enable PAM authentication, account processing, -# and session processing. If this is enabled, PAM authentication will -# be allowed through the ChallengeResponseAuthentication and -# PasswordAuthentication. Depending on your PAM configuration, -# PAM authentication via ChallengeResponseAuthentication may bypass -# the setting of "PermitRootLogin without-password". -# If you just want the PAM account and session checks to run without -# PAM authentication, then enable this but set PasswordAuthentication -# and ChallengeResponseAuthentication to 'no'. -#UsePAM no -UsePAM yes - -# Accept locale-related environment variables -AcceptEnv LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES -AcceptEnv LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT -AcceptEnv LC_IDENTIFICATION LC_ALL LANGUAGE -AcceptEnv XMODIFIERS - -#AllowAgentForwarding yes -#AllowTcpForwarding yes -#GatewayPorts no -#X11Forwarding no -X11Forwarding yes -#X11DisplayOffset 10 -#X11UseLocalhost yes -#PrintMotd yes -#PrintLastLog yes -#TCPKeepAlive yes -#UseLogin no -#UsePrivilegeSeparation yes -#PermitUserEnvironment no -#Compression delayed -#ClientAliveInterval 0 -#ClientAliveCountMax 3 -#ShowPatchLevel no -#UseDNS yes -#PidFile /var/run/sshd.pid -#MaxStartups 10 -#PermitTunnel no -#ChrootDirectory none - -# no default banner path -#Banner none - -# override default of no subsystems -Subsystem sftp /usr/libexec/openssh/sftp-server - -# Example of overriding settings on a per-user basis -Match User anoncvs - X11Forwarding no - AllowTcpForwarding no - ForceCommand cvs server - -Match Host *.example.net User * - AllowAgentForwarding no diff --git a/spec/fixtures/unit/puppet/provider/sysctl/augeas/broken b/spec/fixtures/unit/puppet/provider/sysctl/augeas/broken deleted file mode 100644 index 4bc7d88..0000000 --- a/spec/fixtures/unit/puppet/provider/sysctl/augeas/broken +++ /dev/null @@ -1,26 +0,0 @@ -brokenfile -# Kernel sysctl configuration file -# -# For binary values, 0 is disabled, 1 is enabled. See sysctl(8) and -# sysctl.conf(5) for more details. - -# Controls IP packet forwarding -net.ipv4.ip_forward = 0 - -# Controls source route verification -net.ipv4.conf.default.rp_filter = 1 - -# Do not accept source routing -net.ipv4.conf.default.accept_source_route = 0 - -# Controls the System Request debugging functionality of the kernel -kernel.sysrq = 0 - -# Controls whether core dumps will append the PID to the core filename. -# Useful for debugging multi-threaded applications. -kernel.core_uses_pid = 1 - -# Disable netfilter on bridges. -net.bridge.bridge-nf-call-ip6tables = 0 -net.bridge.bridge-nf-call-iptables = 0 -net.bridge.bridge-nf-call-arptables = 0 diff --git a/spec/fixtures/unit/puppet/provider/sysctl/augeas/empty b/spec/fixtures/unit/puppet/provider/sysctl/augeas/empty deleted file mode 100644 index e69de29..0000000 diff --git a/spec/fixtures/unit/puppet/provider/sysctl/augeas/full b/spec/fixtures/unit/puppet/provider/sysctl/augeas/full deleted file mode 100644 index 181534e..0000000 --- a/spec/fixtures/unit/puppet/provider/sysctl/augeas/full +++ /dev/null @@ -1,26 +0,0 @@ -# Kernel sysctl configuration file -# -# For binary values, 0 is disabled, 1 is enabled. See sysctl(8) and -# sysctl.conf(5) for more details. - -# Controls IP packet forwarding -net.ipv4.ip_forward = 0 - -# Controls source route verification -net.ipv4.conf.default.rp_filter = 1 - -# net.ipv4.conf.default.accept_source_route: Do not accept source routing -net.ipv4.conf.default.accept_source_route = 0 - -# SysRq setting -# kernel.sysrq: controls the System Request debugging functionality of the kernel -kernel.sysrq = 0 - -# Controls whether core dumps will append the PID to the core filename. -# Useful for debugging multi-threaded applications. -kernel.core_uses_pid = 1 - -# Disable netfilter on bridges. -net.bridge.bridge-nf-call-ip6tables = 0 -#net.bridge.bridge-nf-call-iptables = 0 -net.bridge.bridge-nf-call-arptables = 0 diff --git a/spec/fixtures/unit/puppet/provider/sysctl/augeas/small b/spec/fixtures/unit/puppet/provider/sysctl/augeas/small deleted file mode 100644 index 7b6026c..0000000 --- a/spec/fixtures/unit/puppet/provider/sysctl/augeas/small +++ /dev/null @@ -1,8 +0,0 @@ -# Kernel sysctl configuration file -# -# For binary values, 0 is disabled, 1 is enabled. See sysctl(8) and -# sysctl.conf(5) for more details. - -# Controls IP packet forwarding -net.ipv4.ip_forward = 0 - diff --git a/spec/fixtures/unit/puppet/provider/syslog/augeas/broken b/spec/fixtures/unit/puppet/provider/syslog/augeas/broken deleted file mode 100644 index fe2aa3b..0000000 --- a/spec/fixtures/unit/puppet/provider/syslog/augeas/broken +++ /dev/null @@ -1,25 +0,0 @@ -# Log all kernel messages to the console. -# Logging much else clutters up the screen. -#kern.* /dev/console - -# Log anything (except mail) of level info or higher. -# Don't log private authentication messages! -*.info;mail.none;authpriv.none;cron.none /var/log/messages - -# The authpriv file has restricted access. -authpriv.* /var/log/secure - -# Log all the mail messages in one place. -mail.* -/var/log/maillog - -;broken - -# Log cron stuff -cron.* /var/log/cron - -# Everybody gets emergency messages -*.emerg * - -# Save news errors of level crit and higher in a special file. -uucp,news.crit /var/log/spooler - diff --git a/spec/fixtures/unit/puppet/provider/syslog/augeas/empty b/spec/fixtures/unit/puppet/provider/syslog/augeas/empty deleted file mode 100644 index e69de29..0000000 diff --git a/spec/fixtures/unit/puppet/provider/syslog/augeas/full b/spec/fixtures/unit/puppet/provider/syslog/augeas/full deleted file mode 100644 index 2203be8..0000000 --- a/spec/fixtures/unit/puppet/provider/syslog/augeas/full +++ /dev/null @@ -1,23 +0,0 @@ -# Log all kernel messages to the console. -# Logging much else clutters up the screen. -#kern.* /dev/console - -# Log anything (except mail) of level info or higher. -# Don't log private authentication messages! -*.info;mail.none;authpriv.none;cron.none /var/log/messages - -# The authpriv file has restricted access. -authpriv.* /var/log/secure - -# Log all the mail messages in one place. -mail.* -/var/log/maillog - - -# Log cron stuff -cron.* /var/log/cron - -# Everybody gets emergency messages -*.emerg * - -# Save news errors of level crit and higher in a special file. -uucp,news.crit /var/log/spooler diff --git a/spec/fixtures/unit/puppet/provider/syslog/rsyslog/broken b/spec/fixtures/unit/puppet/provider/syslog/rsyslog/broken deleted file mode 100644 index a473265..0000000 --- a/spec/fixtures/unit/puppet/provider/syslog/rsyslog/broken +++ /dev/null @@ -1,82 +0,0 @@ -;broken - -# rsyslog v5 configuration file - -# For more information see /usr/share/doc/rsyslog-*/rsyslog_conf.html -# If you experience problems, see http://www.rsyslog.com/doc/troubleshoot.html - -#### MODULES #### - -$ModLoad imuxsock # provides support for local system logging (e.g. via logger command) -$ModLoad imklog # provides kernel logging support (previously done by rklogd) -#$ModLoad immark # provides --MARK-- message capability - -# Provides UDP syslog reception -#$ModLoad imudp -#$UDPServerRun 514 - -# Provides TCP syslog reception -#$ModLoad imtcp -#$InputTCPServerRun 514 - - -#### GLOBAL DIRECTIVES #### - -# Use default timestamp format -$ActionFileDefaultTemplate RSYSLOG_TraditionalFileFormat - -# File syncing capability is disabled by default. This feature is usually not required, -# not useful and an extreme performance hit -#$ActionFileEnableSync on - -# Include all config files in /etc/rsyslog.d/ -$IncludeConfig /etc/rsyslog.d/*.conf - - -#### RULES #### - -# Log all kernel messages to the console. -# Logging much else clutters up the screen. -#kern.* /dev/console - -# Log anything (except mail) of level info or higher. -# Don't log private authentication messages! -*.info;mail.none;authpriv.none;cron.none /var/log/messages - -# The authpriv file has restricted access. -authpriv.* /var/log/secure - -# Log all the mail messages in one place. -mail.* -/var/log/maillog - - -# Log cron stuff -cron.* /var/log/cron - -# Everybody gets emergency messages -*.emerg :omusrmsg:* - -# Save news errors of level crit and higher in a special file. -uucp,news.crit /var/log/spooler - -# Save boot messages also to boot.log -local7.* /var/log/boot.log - - -# ### begin forwarding rule ### -# The statement between the begin ... end define a SINGLE forwarding -# rule. They belong together, do NOT split them. If you create multiple -# forwarding rules, duplicate the whole block! -# Remote Logging (we use TCP for reliable delivery) -# -# An on-disk queue is created for this action. If the remote host is -# down, messages are spooled to disk and sent when it is up again. -#$WorkDirectory /var/lib/rsyslog # where to place spool files -#$ActionQueueFileName fwdRule1 # unique name prefix for spool files -#$ActionQueueMaxDiskSpace 1g # 1gb space limit (use as much as possible) -#$ActionQueueSaveOnShutdown on # save messages to disk on shutdown -#$ActionQueueType LinkedList # run asynchronously -#$ActionResumeRetryCount -1 # infinite retries if host is down -# remote host is: name/ip:port, e.g. 192.168.0.1:514, port optional -#*.* @@remote-host:514 -# ### end of the forwarding rule ### diff --git a/spec/fixtures/unit/puppet/provider/syslog/rsyslog/empty b/spec/fixtures/unit/puppet/provider/syslog/rsyslog/empty deleted file mode 100644 index e69de29..0000000 diff --git a/spec/fixtures/unit/puppet/provider/syslog/rsyslog/full b/spec/fixtures/unit/puppet/provider/syslog/rsyslog/full deleted file mode 100644 index a7adde3..0000000 --- a/spec/fixtures/unit/puppet/provider/syslog/rsyslog/full +++ /dev/null @@ -1,80 +0,0 @@ -# rsyslog v5 configuration file - -# For more information see /usr/share/doc/rsyslog-*/rsyslog_conf.html -# If you experience problems, see http://www.rsyslog.com/doc/troubleshoot.html - -#### MODULES #### - -$ModLoad imuxsock # provides support for local system logging (e.g. via logger command) -$ModLoad imklog # provides kernel logging support (previously done by rklogd) -#$ModLoad immark # provides --MARK-- message capability - -# Provides UDP syslog reception -#$ModLoad imudp -#$UDPServerRun 514 - -# Provides TCP syslog reception -#$ModLoad imtcp -#$InputTCPServerRun 514 - - -#### GLOBAL DIRECTIVES #### - -# Use default timestamp format -$ActionFileDefaultTemplate RSYSLOG_TraditionalFileFormat - -# File syncing capability is disabled by default. This feature is usually not required, -# not useful and an extreme performance hit -#$ActionFileEnableSync on - -# Include all config files in /etc/rsyslog.d/ -$IncludeConfig /etc/rsyslog.d/*.conf - - -#### RULES #### - -# Log all kernel messages to the console. -# Logging much else clutters up the screen. -#kern.* /dev/console - -# Log anything (except mail) of level info or higher. -# Don't log private authentication messages! -*.info;mail.none;authpriv.none;cron.none /var/log/messages - -# The authpriv file has restricted access. -authpriv.* /var/log/secure - -# Log all the mail messages in one place. -mail.* -/var/log/maillog - - -# Log cron stuff -cron.* /var/log/cron - -# Everybody gets emergency messages -#*.emerg :omusrmsg:* - -# Save news errors of level crit and higher in a special file. -uucp,news.crit /var/log/spooler - -# Save boot messages also to boot.log -local7.* /var/log/boot.log - - -# ### begin forwarding rule ### -# The statement between the begin ... end define a SINGLE forwarding -# rule. They belong together, do NOT split them. If you create multiple -# forwarding rules, duplicate the whole block! -# Remote Logging (we use TCP for reliable delivery) -# -# An on-disk queue is created for this action. If the remote host is -# down, messages are spooled to disk and sent when it is up again. -#$WorkDirectory /var/lib/rsyslog # where to place spool files -#$ActionQueueFileName fwdRule1 # unique name prefix for spool files -#$ActionQueueMaxDiskSpace 1g # 1gb space limit (use as much as possible) -#$ActionQueueSaveOnShutdown on # save messages to disk on shutdown -#$ActionQueueType LinkedList # run asynchronously -#$ActionResumeRetryCount -1 # infinite retries if host is down -# remote host is: name/ip:port, e.g. 192.168.0.1:514, port optional -#*.* @@remote-host:514 -# ### end of the forwarding rule ### diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 2913b92..c2d138a 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -19,24 +19,3 @@ require 'augeas_spec' Puppet[:modulepath] = File.join(dir, 'fixtures', 'modules') - -# There's no real need to make this version dependent, but it helps find -# regressions in Puppet -# -# 1. Workaround for issue #16277 where default settings aren't initialised from -# a spec and so the libdir is never initialised (3.0.x) -# 2. Workaround for 2.7.20 that now only loads types for the current node -# environment (#13858) so Puppet[:modulepath] seems to get ignored -# 3. Workaround for 3.5 where context hasn't been configured yet, -# ticket https://tickets.puppetlabs.com/browse/MODULES-823 -# -ver = Gem::Version.new(Puppet.version.split('-').first) -if Gem::Requirement.new("~> 2.7.20") =~ ver || Gem::Requirement.new("~> 3.0.0") =~ ver || Gem::Requirement.new("~> 3.5") =~ ver - puts "augeasproviders: setting Puppet[:libdir] to work around broken type autoloading" - # libdir is only a single dir, so it can only workaround loading of one external module - Puppet[:libdir] = "#{Puppet[:modulepath]}/mount_providers/lib" - $LOAD_PATH.unshift(File.join(dir, 'fixtures/modules/stdlib/lib')) -end - -# Load all shared contexts and shared examples -Dir["#{dir}/support/**/*.rb"].sort.each {|f| require f} diff --git a/spec/unit/puppet/provider/apache_directive/augeas_spec.rb b/spec/unit/puppet/provider/apache_directive/augeas_spec.rb deleted file mode 100644 index 64c026f..0000000 --- a/spec/unit/puppet/provider/apache_directive/augeas_spec.rb +++ /dev/null @@ -1,192 +0,0 @@ -#!/usr/bin/env rspec - -require 'spec_helper' - -FileTest.stubs(:exist?).returns false -FileTest.stubs(:exist?).with('/etc/apache2/apache2.conf').returns true -provider_class = Puppet::Type.type(:apache_directive).provider(:augeas) - -describe provider_class do - before :each do - FileTest.stubs(:exist?).returns false - Facter.fact(:osfamily).stubs(:value).returns 'Debian' - FileTest.stubs(:exist?).with('/etc/apache2/apache2.conf').returns true - end - - context "with empty file" do - let(:tmptarget) { aug_fixture("empty") } - let(:target) { tmptarget.path } - - it "should create simple new entry" do - apply!(Puppet::Type.type(:apache_directive).new( - :name => 'StartServers', - :args => '3', - :ensure => "present", - :target => target, - :provider => 'augeas' - )) - - augparse(target, "Httpd.lns", '{ "directive" = "StartServers" { "arg" = "3" } }') - end - end - - context "with full file" do - let(:tmptarget) { aug_fixture("full") } - let(:target) { tmptarget.path } - - it "should list instances" do - provider_class.stubs(:target).returns(target) - inst = provider_class.instances.map { |p| - { - :name => p.get(:name), - :ensure => p.get(:ensure), - :args => p.get(:args), - :context => p.get(:context) - } - } - - inst.size.should == 49 - inst[0].should == {:args=>["${APACHE_LOCK_DIR}/accept.lock"], :name=>"LockFile", :ensure=>:present, :context=>""} - inst[5].should == {:args=>["5"], :name=>"KeepAliveTimeout", :ensure=>:present, :context=>""} - inst[30].should == {:args=>["150"], :context=>"IfModule[1]", :name=>"MaxClients", :ensure=>:present} - end - end - - context "with simple file" do - let(:tmptarget) { aug_fixture("simple") } - let(:target) { tmptarget.path } - - it "should create simple new entry" do - apply!(Puppet::Type.type(:apache_directive).new( - :name => 'StartServers', - :args => '3', - :ensure => "present", - :target => target, - :provider => 'augeas' - )) - - # New entry gets added next to existing SetEnv entries - augparse(target, "Httpd.lns", ' - { "directive" = "SetEnv" { "arg" = "TEST" } } - { "directive" = "SetEnv" { "arg" = "FQDN" } { "arg" = "ignored" } } - { "directive" = "SetEnv" { "arg" = "FQDN" } { "arg" = "test.com" } } - { "directive" = "Example" } - { "directive" = "StartServers" { "arg" = "3" } } - ') - end - - context "when updating existing" do - it "should update existing" do - apply!(Puppet::Type.type(:apache_directive).new( - :name => 'Timeout', - :args => '0', - :ensure => "present", - :target => target, - :provider => "augeas" - )) - - aug_open(target, "Httpd.lns") do |aug| - aug.get("directive[.='Timeout']/arg").should == '0' - end - end - - it "should clear args when only one arg" do - apply!(Puppet::Type.type(:apache_directive).new( - :name => 'SetEnv', - :args => ['FQDN'], - :args_params => 1, - :ensure => "present", - :target => target, - :provider => "augeas" - )) - augparse(target, "Httpd.lns", ' - { "directive" = "SetEnv" { "arg" = "TEST" } } - { "directive" = "SetEnv" { "arg" = "FQDN" } } - { "directive" = "Example" } - ') - end - end - - context "when creating with context" do - it "creating should create directive" do - apply!(Puppet::Type.type(:apache_directive).new( - :name => 'StartServers', - :args_params => 0, - :args => ['2'], - :context => "IfModule[1]", - :ensure => "present", - :target => target, - :provider => "augeas" - )) - - augparse(target, "Httpd.lns", ' - { "directive" = "SetEnv" { "arg" = "TEST" } } - { "directive" = "SetEnv" { "arg" = "FQDN" } { "arg" = "ignored" } } - { "directive" = "SetEnv" { "arg" = "FQDN" } { "arg" = "test.com" } } - { "directive" = "Example" } - { "IfModule" { "directive" = "StartServers" { "arg" = "2" } } } - ') - aug_open(target, "Httpd.lns") do |aug| - aug.get("IfModule[1]/directive[.='StartServers']/arg").should == '2' - end - end - end - - it "should delete entries" do - apply!(Puppet::Type.type(:apache_directive).new( - :name => 'Timeout', - :args => '0', - :ensure => "absent", - :target => target, - :provider => "augeas" - )) - - aug_open(target, "Httpd.lns") do |aug| - aug.match("directive[.='Timeout']").size.should == 0 - end - end - end - - context "with full file" do - let(:tmptarget) { aug_fixture("full") } - let(:target) { tmptarget.path } - - context "when using context" do - it "updating should update value" do - apply!(Puppet::Type.type(:apache_directive).new( - :name => 'StartServers', - :args_params => 0, - :args => 2, - :context => "IfModule[arg='mpm_worker_module']", - :ensure => "present", - :target => target, - :provider => "augeas" - )) - - aug_open(target, "Httpd.lns") do |aug| - aug.get("IfModule[arg='mpm_worker_module']/directive[.='StartServers']/arg").should == '2' - end - end - end - end - - - context "with broken file" do - let(:tmptarget) { aug_fixture("broken") } - let(:target) { tmptarget.path } - - it "should fail to load" do - txn = apply(Puppet::Type.type(:apache_directive).new( - :name => 'SetEnv', - :args => ['FQDN', 'test.com'], - :ensure => "present", - :target => target, - :provider => "augeas" - )) - - txn.any_failed?.should_not == nil - @logs.first.level.should == :err - @logs.first.message.include?(target).should == true - end - end -end diff --git a/spec/unit/puppet/provider/apache_setenv/augeas_spec.rb b/spec/unit/puppet/provider/apache_setenv/augeas_spec.rb deleted file mode 100644 index 91844e9..0000000 --- a/spec/unit/puppet/provider/apache_setenv/augeas_spec.rb +++ /dev/null @@ -1,153 +0,0 @@ -#!/usr/bin/env rspec - -require 'spec_helper' - -FileTest.stubs(:exist?).returns false -FileTest.stubs(:exist?).with('/etc/apache2/apache2.conf').returns true -provider_class = Puppet::Type.type(:apache_setenv).provider(:augeas) - -describe provider_class do - before :each do - FileTest.stubs(:exist?).returns false - FileTest.stubs(:exist?).with('/etc/apache2/apache2.conf').returns true - end - - context "with empty file" do - let(:tmptarget) { aug_fixture("empty") } - let(:target) { tmptarget.path } - - it "should create simple new entry" do - apply!(Puppet::Type.type(:apache_setenv).new( - :name => 'TEST', - :value => 'test', - :ensure => "present", - :target => target, - :provider => 'augeas' - )) - - augparse(target, "Httpd.lns", '{ "directive" = "SetEnv" { "arg" = "TEST" } { "arg" = "test" } }') - end - end - - context "with full file" do - let(:tmptarget) { aug_fixture("full") } - let(:target) { tmptarget.path } - - it "should list instances" do - provider_class.stubs(:target).returns(target) - inst = provider_class.instances.map { |p| - { - :name => p.get(:name), - :ensure => p.get(:ensure), - :value => p.get(:value) - } - } - - inst.size.should == 2 - inst[0].should == {:name=>"TEST", :ensure=>:present, :value=>"test"} - inst[1].should == {:name=>"TEST2", :ensure=>:present, :value=>:absent} - end - end - - context "with simple file" do - let(:tmptarget) { aug_fixture("simple") } - let(:target) { tmptarget.path } - - it "should create simple new entry" do - apply!(Puppet::Type.type(:apache_setenv).new( - :name => 'FOO', - :value => 'test', - :ensure => "present", - :target => target, - :provider => 'augeas' - )) - - # New entry gets added next to existing SetEnv entries - augparse(target, "Httpd.lns", ' - { "directive" = "SetEnv" { "arg" = "TEST" } } - { "directive" = "SetEnv" { "arg" = "FQDN" } { "arg" = "ignored" } } - { "directive" = "SetEnv" { "arg" = "FQDN" } { "arg" = "test.com" } } - { "directive" = "SetEnv" { "arg" = "FOO" } { "arg" = "test" } } - { "directive" = "Example" } - ') - end - - describe "when update existing" do - it "should update existing" do - apply!(Puppet::Type.type(:apache_setenv).new( - :name => "FQDN", - :value => 'test2.com', - :ensure => "present", - :target => target, - :provider => "augeas" - )) - - # Should have deleted the second FQDN entry - aug_open(target, "Httpd.lns") do |aug| - aug.match("directive[.='SetEnv' and arg[1]='FQDN']").size.should == 1 - end - - augparse(target, "Httpd.lns", ' - { "directive" = "SetEnv" - { "arg" = "TEST" } - } - { "directive" = "SetEnv" - { "arg" = "FQDN" } - { "arg" = "test2.com" } - } - { "directive" = "Example" } - ') - end - - it "should clear value when no value" do - apply!(Puppet::Type.type(:apache_setenv).new( - :name => "FQDN", - :value => "", - :ensure => "present", - :target => target, - :provider => "augeas" - )) - augparse(target, "Httpd.lns", ' - { "directive" = "SetEnv" { "arg" = "TEST" } } - { "directive" = "SetEnv" { "arg" = "FQDN" } } - { "directive" = "Example" } - ') - end - end - - it "should delete entries" do - apply!(Puppet::Type.type(:apache_setenv).new( - :name => "FQDN", - :ensure => "absent", - :target => target, - :provider => "augeas" - )) - - augparse(target, "Httpd.lns", ' - { "directive" = "SetEnv" - { "arg" = "TEST" } - } - { "directive" = "Example" } - ') - end - end - - context "with broken file" do - let(:tmptarget) { aug_fixture("broken") } - let(:target) { tmptarget.path } - - it "should fail to load" do - txn = apply(Puppet::Type.type(:apache_setenv).new( - :name => "FQDN", - :value => "test.com", - :ensure => "present", - :target => target, - :provider => "augeas" - )) - - txn.any_failed?.should_not == nil - @logs.first.level.should == :err - @logs.first.message.include?(target).should == true - end - end -end diff --git a/spec/unit/puppet/provider/host/augeas_spec.rb b/spec/unit/puppet/provider/host/augeas_spec.rb deleted file mode 100755 index 5b28879..0000000 --- a/spec/unit/puppet/provider/host/augeas_spec.rb +++ /dev/null @@ -1,274 +0,0 @@ -#!/usr/bin/env rspec - -require 'spec_helper' - -provider_class = Puppet::Type.type(:host).provider(:augeas) - -describe provider_class do - before :all do - # Pre-2.7.0, there was no comment property on the host type so this will - # produce errors while testing against old versions, so add it. - # Don't call validattr? or this keeps a negative cache of the property - unless Puppet::Type.type(:host).validproperty? :comment - Puppet::Type.type(:host).newproperty(:comment) do - desc "Monkey patched" - end - end - end - - before :each do - FileTest.stubs(:exist?).returns false - FileTest.stubs(:exist?).with('/etc/hosts').returns true - end - - context "with empty file" do - let(:tmptarget) { aug_fixture("empty") } - let(:target) { tmptarget.path } - - it "should create simple new entry" do - apply!(Puppet::Type.type(:host).new( - :name => "foo", - :ip => "192.168.1.1", - :target => target, - :provider => "augeas" - )) - - augparse(target, "Hosts.lns", ' - { "1" - { "ipaddr" = "192.168.1.1" } - { "canonical" = "foo" } - } - ') - end - - it "should create new entry" do - apply!(Puppet::Type.type(:host).new( - :name => "foo", - :ip => "192.168.1.1", - :host_aliases => [ "foo-a", "foo-b" ], - :comment => "test", - :target => target, - :provider => "augeas" - )) - - augparse(target, "Hosts.lns", ' - { "1" - { "ipaddr" = "192.168.1.1" } - { "canonical" = "foo" } - { "alias" = "foo-a" } - { "alias" = "foo-b" } - { "#comment" = "test" } - } - ') - end - end - - context "with full file" do - let(:tmptarget) { aug_fixture("full") } - let(:target) { tmptarget.path } - - it "should list instances" do - provider_class.stubs(:target).returns(target) - inst = provider_class.instances.map { |p| - { - :name => p.get(:name), - :ensure => p.get(:ensure), - :ip => p.get(:ip), - :host_aliases => p.get(:host_aliases), - :comment => p.get(:comment), - } - } - - inst.size.should == 4 - inst[0].should == {:name=>"localhost.localdomain", :ensure=>:present, :ip=>"127.0.0.1", :host_aliases=>["localhost"], :comment=>:absent} - inst[1].should == {:name=>"localhost6.localdomain6", :ensure=>:present, :ip=>"::1", :host_aliases=>["localhost6"], :comment=>:absent} - inst[2].should == {:name=>"iridium", :ensure=>:present, :ip=>"192.168.0.5", :host_aliases=>["iridium.example.com"], :comment=>:absent} - inst[3].should == {:name=>"argon", :ensure=>:present, :ip=>"192.168.0.10", :host_aliases=>:absent, :comment=>"NAS"} - end - - it "should delete entries" do - apply!(Puppet::Type.type(:host).new( - :name => "iridium", - :ensure => "absent", - :target => target, - :provider => "augeas" - )) - - aug_open(target, "Hosts.lns") do |aug| - aug.match("*[canonical = 'iridium']").should == [] - end - end - - it "should update IP address" do - apply!(Puppet::Type.type(:host).new( - :name => "iridium", - :ip => "1.2.3.4", - :target => target, - :provider => "augeas" - )) - - augparse_filter(target, "Hosts.lns", "*[canonical='iridium']", ' - { "1" - { "ipaddr" = "1.2.3.4" } - { "canonical" = "iridium" } - { "alias" = "iridium.example.com" } - } - ') - end - - describe "when updating host_aliases" do - it "should add an alias" do - apply!(Puppet::Type.type(:host).new( - :name => "argon", - :host_aliases => [ "test-a" ], - :target => target, - :provider => "augeas" - )) - - augparse_filter(target, "Hosts.lns", "*[canonical='argon']", ' - { "1" - { "ipaddr" = "192.168.0.10" } - { "canonical" = "argon" } - { "alias" = "test-a" } - { "#comment" = "NAS" } - } - ') - end - - it "should replace an alias" do - apply!(Puppet::Type.type(:host).new( - :name => "iridium", - :host_aliases => [ "test-a" ], - :target => target, - :provider => "augeas" - )) - - augparse_filter(target, "Hosts.lns", "*[canonical='iridium']", ' - { "1" - { "ipaddr" = "192.168.0.5" } - { "canonical" = "iridium" } - { "alias" = "test-a" } - } - ') - end - - it "should add multiple aliases" do - apply!(Puppet::Type.type(:host).new( - :name => "iridium", - :host_aliases => [ "test-a", "test-b" ], - :target => target, - :provider => "augeas" - )) - - augparse_filter(target, "Hosts.lns", "*[canonical='iridium']", ' - { "1" - { "ipaddr" = "192.168.0.5" } - { "canonical" = "iridium" } - { "alias" = "test-a" } - { "alias" = "test-b" } - } - ') - end - - it "should remove aliases" do - apply!(Puppet::Type.type(:host).new( - :name => "iridium", - :host_aliases => [ ], - :target => target, - :provider => "augeas" - )) - - augparse_filter(target, "Hosts.lns", "*[canonical='iridium']", ' - { "1" - { "ipaddr" = "192.168.0.5" } - { "canonical" = "iridium" } - } - ') - end - end - - describe "when updating comment" do - it "should add comment" do - apply!(Puppet::Type.type(:host).new( - :name => "iridium", - :comment => "test comment", - :target => target, - :provider => "augeas" - )) - - augparse_filter(target, "Hosts.lns", "*[canonical='iridium']", ' - { "1" - { "ipaddr" = "192.168.0.5" } - { "canonical" = "iridium" } - { "alias" = "iridium.example.com" } - { "#comment" = "test comment" } - } - ') - end - - it "should remove comment" do - apply!(Puppet::Type.type(:host).new( - :name => "argon", - :comment => "", - :target => target, - :provider => "augeas" - )) - - augparse_filter(target, "Hosts.lns", "*[canonical='argon']", ' - { "1" - { "ipaddr" = "192.168.0.10" } - { "canonical" = "argon" } - } - ') - end - end - end - - context "with broken file" do - let(:tmptarget) { aug_fixture("broken") } - let(:target) { tmptarget.path } - - it "should fail to load" do - txn = apply(Puppet::Type.type(:host).new( - :name => "foo", - :ip => "192.168.1.1", - :target => target, - :provider => "augeas" - )) - - txn.any_failed?.should_not == nil - @logs.first.level.should == :err - @logs.first.message.include?(target).should == true - end - end - - context "without comment property on <2.7" do - let(:tmptarget) { aug_fixture("full") } - let(:target) { tmptarget.path } - - before :each do - # Change Puppet::Type::Host.validattr? to return false instead for - # comment so it throws the same errors as Puppet < 2.7 - validattr = Puppet::Type.type(:host).method(:validattr?) - Puppet::Type.type(:host).stubs(:validattr?).with { |arg| validattr.call(arg) }.returns(true) - Puppet::Type.type(:host).stubs(:validattr?).with { |arg| ! validattr.call(arg) }.returns(false) - Puppet::Type.type(:host).stubs(:validattr?).with(:comment).returns(false) - end - - it "should create simple new entry" do - apply!(Puppet::Type.type(:host).new( - :name => "foo", - :ip => "192.168.1.1", - :target => target, - :provider => "augeas" - )) - - augparse_filter(target, "Hosts.lns", "*[canonical='foo']", ' - { "1" - { "ipaddr" = "192.168.1.1" } - { "canonical" = "foo" } - } - ') - end - end -end diff --git a/spec/unit/puppet/provider/kernel_parameter/grub2_spec.rb b/spec/unit/puppet/provider/kernel_parameter/grub2_spec.rb deleted file mode 100755 index 389cb56..0000000 --- a/spec/unit/puppet/provider/kernel_parameter/grub2_spec.rb +++ /dev/null @@ -1,324 +0,0 @@ -#!/usr/bin/env rspec - -require 'spec_helper' -provider_class = Puppet::Type.type(:kernel_parameter).provider(:grub2) - -LENS = "Shellvars_list.lns" -FILTER = "*[label() =~ regexp('GRUB_CMDLINE_LINUX.*')]" - -describe provider_class do - it "should find grub2-mkconfig" do - FileTest.stubs(:file?).returns false - FileTest.stubs(:executable?).returns false - FileTest.stubs(:file?).with('/usr/sbin/grub2-mkconfig').returns true - FileTest.stubs(:executable?).with('/usr/sbin/grub2-mkconfig').returns true - provider_class.mkconfig_path.should == '/usr/sbin/grub2-mkconfig' - end - - it "should find grub-mkconfig" do - FileTest.stubs(:file?).returns false - FileTest.stubs(:executable?).returns false - FileTest.stubs(:file?).with('/usr/sbin/grub-mkconfig').returns true - FileTest.stubs(:executable?).with('/usr/sbin/grub-mkconfig').returns true - provider_class.mkconfig_path.should == '/usr/sbin/grub-mkconfig' - end -end - -describe provider_class do - before :each do - provider_class.stubs(:default?).returns(true) - FileTest.stubs(:exist?).returns false - FileTest.stubs(:file?).returns false - FileTest.stubs(:executable?).returns false - [ '/usr/sbin/grub2-mkconfig', '/usr/sbin/grub-mkconfig' ].each do |path| - FileTest.stubs(:file?).with(path).returns true - FileTest.stubs(:exist?).with(path).returns true - FileTest.stubs(:executable?).with(path).returns true - end - FileTest.stubs(:file?).with('/boot/grub2/grub.cfg').returns true - FileTest.stubs(:exist?).with('/etc/default/grub').returns true - end - - context "with full file" do - let(:tmptarget) { aug_fixture("full") } - let(:target) { tmptarget.path } - - it "should list instances" do - provider_class.stubs(:target).returns(target) - inst = provider_class.instances.map { |p| - { - :name => p.get(:name), - :ensure => p.get(:ensure), - :value => p.get(:value), - :bootmode => p.get(:bootmode), - } - } - - inst.size.should == 4 - inst[0].should == {:name=>"quiet", :ensure=>:present, :value=>:absent, :bootmode=>"all"} - inst[1].should == {:name=>"elevator", :ensure=>:present, :value=>"noop", :bootmode=>"all"} - inst[2].should == {:name=>"divider", :ensure=>:present, :value=>"10", :bootmode=>"all"} - inst[3].should == {:name=>"rhgb", :ensure=>:present, :value=>:absent, :bootmode=>"normal"} - end - - describe "when creating entries" do - before :each do - provider_class.any_instance.expects(:mkconfig).with("-o", "/boot/grub2/grub.cfg") - end - - it "should create no-value entries" do - apply!(Puppet::Type.type(:kernel_parameter).new( - :name => "foo", - :ensure => :present, - :target => target, - :provider => "grub2" - )) - - augparse_filter(target, LENS, FILTER, ' - { "GRUB_CMDLINE_LINUX" - { "quote" = "\"" } - { "value" = "quiet" } - { "value" = "elevator=noop" } - { "value" = "divider=10" } - { "value" = "foo" } - } - { "GRUB_CMDLINE_LINUX_DEFAULT" - { "quote" = "\"" } - { "value" = "rhgb" } - } - ') - end - - it "should create entry with value" do - apply!(Puppet::Type.type(:kernel_parameter).new( - :name => "foo", - :ensure => :present, - :value => "bar", - :target => target, - :provider => "grub2" - )) - - augparse_filter(target, LENS, FILTER, ' - { "GRUB_CMDLINE_LINUX" - { "quote" = "\"" } - { "value" = "quiet" } - { "value" = "elevator=noop" } - { "value" = "divider=10" } - { "value" = "foo=bar" } - } - { "GRUB_CMDLINE_LINUX_DEFAULT" - { "quote" = "\"" } - { "value" = "rhgb" } - } - ') - end - - it "should create entries with multiple values" do - apply!(Puppet::Type.type(:kernel_parameter).new( - :name => "foo", - :ensure => :present, - :value => ["bar", "baz"], - :target => target, - :provider => "grub2" - )) - - augparse_filter(target, LENS, FILTER, ' - { "GRUB_CMDLINE_LINUX" - { "quote" = "\"" } - { "value" = "quiet" } - { "value" = "elevator=noop" } - { "value" = "divider=10" } - { "value" = "foo=bar" } - { "value" = "foo=baz" } - } - { "GRUB_CMDLINE_LINUX_DEFAULT" - { "quote" = "\"" } - { "value" = "rhgb" } - } - ') - end - - it "should create normal boot-only entries" do - apply!(Puppet::Type.type(:kernel_parameter).new( - :name => "foo", - :ensure => :present, - :bootmode => :normal, - :target => target, - :provider => "grub2" - )) - - augparse_filter(target, LENS, FILTER, ' - { "GRUB_CMDLINE_LINUX" - { "quote" = "\"" } - { "value" = "quiet" } - { "value" = "elevator=noop" } - { "value" = "divider=10" } - } - { "GRUB_CMDLINE_LINUX_DEFAULT" - { "quote" = "\"" } - { "value" = "rhgb" } - { "value" = "foo" } - } - ') - end - end - - it "should error on recovery-only entries" do - txn = apply(Puppet::Type.type(:kernel_parameter).new( - :name => "foo", - :ensure => :present, - :bootmode => :recovery, - :target => target, - :provider => "grub2" - )) - - txn.any_failed?.should_not == nil - @logs.first.level.should == :err - @logs.first.message.include?("Unsupported bootmode").should == true - end - - it "should delete entries" do - provider_class.any_instance.expects(:mkconfig).with("-o", "/boot/grub2/grub.cfg") - - apply!(Puppet::Type.type(:kernel_parameter).new( - :name => "divider", - :ensure => "absent", - :target => target, - :provider => "grub2" - )) - - augparse_filter(target, LENS, FILTER, ' - { "GRUB_CMDLINE_LINUX" - { "quote" = "\"" } - { "value" = "quiet" } - { "value" = "elevator=noop" } - } - { "GRUB_CMDLINE_LINUX_DEFAULT" - { "quote" = "\"" } - { "value" = "rhgb" } - } - ') - end - - describe "when modifying values" do - before :each do - provider_class.any_instance.stubs(:create).never - end - - it "should change existing values" do - provider_class.any_instance.expects(:mkconfig).with("-o", "/boot/grub2/grub.cfg") - apply!(Puppet::Type.type(:kernel_parameter).new( - :name => "elevator", - :ensure => :present, - :value => "deadline", - :target => target, - :provider => "grub2" - )) - - augparse_filter(target, LENS, FILTER, ' - { "GRUB_CMDLINE_LINUX" - { "quote" = "\"" } - { "value" = "quiet" } - { "value" = "elevator=deadline" } - { "value" = "divider=10" } - } - { "GRUB_CMDLINE_LINUX_DEFAULT" - { "quote" = "\"" } - { "value" = "rhgb" } - } - ') - end - - it "should add value to entry" do - provider_class.any_instance.expects(:mkconfig).with("-o", "/boot/grub2/grub.cfg") - apply!(Puppet::Type.type(:kernel_parameter).new( - :name => "quiet", - :ensure => :present, - :value => "foo", - :target => target, - :provider => "grub2" - )) - - augparse_filter(target, LENS, FILTER, ' - { "GRUB_CMDLINE_LINUX" - { "quote" = "\"" } - { "value" = "quiet=foo" } - { "value" = "elevator=noop" } - { "value" = "divider=10" } - } - { "GRUB_CMDLINE_LINUX_DEFAULT" - { "quote" = "\"" } - { "value" = "rhgb" } - } - ') - end - - it "should add and remove entries for multiple values" do - provider_class.any_instance.expects(:mkconfig).with("-o", "/boot/grub2/grub.cfg").times(2) - - # Add multiple entries - apply!(Puppet::Type.type(:kernel_parameter).new( - :name => "elevator", - :ensure => :present, - :value => ["noop", "deadline"], - :target => target, - :provider => "grub2" - )) - - augparse_filter(target, LENS, FILTER, ' - { "GRUB_CMDLINE_LINUX" - { "quote" = "\"" } - { "value" = "quiet" } - { "value" = "elevator=noop" } - { "value" = "divider=10" } - { "value" = "elevator=deadline" } - } - { "GRUB_CMDLINE_LINUX_DEFAULT" - { "quote" = "\"" } - { "value" = "rhgb" } - } - ') - - # Remove one excess entry - apply!(Puppet::Type.type(:kernel_parameter).new( - :name => "elevator", - :ensure => :present, - :value => ["deadline"], - :target => target, - :provider => "grub2" - )) - - augparse_filter(target, LENS, FILTER, ' - { "GRUB_CMDLINE_LINUX" - { "quote" = "\"" } - { "value" = "quiet" } - { "value" = "elevator=deadline" } - { "value" = "divider=10" } - } - { "GRUB_CMDLINE_LINUX_DEFAULT" - { "quote" = "\"" } - { "value" = "rhgb" } - } - ') - end - end - end - - context "with broken file" do - let(:tmptarget) { aug_fixture("broken") } - let(:target) { tmptarget.path } - - it "should fail to load" do - txn = apply(Puppet::Type.type(:kernel_parameter).new( - :name => "foo", - :ensure => :present, - :target => target, - :provider => "grub2" - )) - - txn.any_failed?.should_not == nil - @logs.first.level.should == :err - @logs.first.message.include?(target).should == true - end - end -end diff --git a/spec/unit/puppet/provider/kernel_parameter/grub_spec.rb b/spec/unit/puppet/provider/kernel_parameter/grub_spec.rb deleted file mode 100755 index 1364177..0000000 --- a/spec/unit/puppet/provider/kernel_parameter/grub_spec.rb +++ /dev/null @@ -1,280 +0,0 @@ -#!/usr/bin/env rspec - -require 'spec_helper' - -provider_class = Puppet::Type.type(:kernel_parameter).provider(:grub) - -describe provider_class do - before :each do - provider_class.stubs(:default?).returns(true) - FileTest.stubs(:exist?).returns false - FileTest.stubs(:executable?).returns false - FileTest.stubs(:exist?).with('/boot/grub/menu.lst').returns true - end - - describe "when finding GRUB config" do - it "should find EFI config when present" do - FileTest.stubs(:exist?).with('/boot/efi/EFI/redhat/grub.conf').returns true - provider_class.target.should == '/boot/efi/EFI/redhat/grub.conf' - end - - it "should default to BIOS config" do - FileTest.stubs(:exist?).with('/boot/efi/EFI/redhat/grub.conf').returns false - provider_class.target.should == '/boot/grub/menu.lst' - end - end - - context "with full file" do - let(:tmptarget) { aug_fixture("full") } - let(:target) { tmptarget.path } - - it "should list instances" do - provider_class.stubs(:target).returns(target) - inst = provider_class.instances.map { |p| - { - :name => p.get(:name), - :ensure => p.get(:ensure), - :value => p.get(:value), - :bootmode => p.get(:bootmode), - } - } - - inst.size.should == 8 - inst[0].should == {:name=>"ro", :ensure=>:present, :value=>:absent, :bootmode=>:all} - inst[1].should == {:name=>"root", :ensure=>:present, :value=>"/dev/VolGroup00/LogVol00", :bootmode=>:all} - inst[2].should == {:name=>"rhgb", :ensure=>:present, :value=>:absent, :bootmode=>:normal} - inst[3].should == {:name=>"quiet", :ensure=>:present, :value=>:absent, :bootmode=>:normal} - inst[4].should == {:name=>"elevator", :ensure=>:present, :value=>"noop", :bootmode=>:all} - inst[5].should == {:name=>"divider", :ensure=>:present, :value=>"10", :bootmode=>:all} - inst[6].should == {:name=>"rd_LVM_LV", :ensure=>:present, :value=>["vg/lv1", "vg/lv2"], :bootmode=>:normal} - inst[7].should == {:name=>"S", :ensure=>:present, :value=>:absent, :bootmode=>:recovery} - end - - describe "when creating entries" do - it "should create no-value entries" do - apply!(Puppet::Type.type(:kernel_parameter).new( - :name => "foo", - :ensure => :present, - :target => target, - :provider => "grub" - )) - - aug_open(target, "Grub.lns") do |aug| - aug.match("title/kernel/foo").size.should == 3 - aug.match("title/kernel/foo").map {|p| aug.get(p)}.should == [nil]*3 - end - end - - it "should create entry with value" do - apply!(Puppet::Type.type(:kernel_parameter).new( - :name => "foo", - :ensure => :present, - :value => "bar", - :target => target, - :provider => "grub" - )) - - aug_open(target, "Grub.lns") do |aug| - aug.match("title/kernel/foo").size.should == 3 - aug.match("title/kernel/foo").map {|p| aug.get(p)}.should == ["bar"]*3 - end - end - - it "should create entries with multiple values" do - apply!(Puppet::Type.type(:kernel_parameter).new( - :name => "foo", - :ensure => :present, - :value => ["bar", "baz"], - :target => target, - :provider => "grub" - )) - - aug_open(target, "Grub.lns") do |aug| - aug.match("title/kernel/foo").size.should == 6 - aug.match("title/kernel/foo").map {|p| aug.get(p)}.should == ["bar", "baz"]*3 - end - end - - # This is a "create" because rd_LVM_LV only exists on one entry in the - # fixture. If it was on all, it would be a modification. - it "should change existing values if present" do - apply!(Puppet::Type.type(:kernel_parameter).new( - :name => "rd_LVM_LV", - :ensure => :present, - :value => ["vg/lv7", "vg/lv8", "vg/lv9"], - :target => target, - :provider => "grub" - )) - - aug_open(target, "Grub.lns") do |aug| - aug.match("title/kernel/rd_LVM_LV").size.should == 9 - aug.match("title/kernel/rd_LVM_LV[.='vg/lv1']").size.should == 0 - aug.match("title/kernel/rd_LVM_LV[.='vg/lv2']").size.should == 0 - aug.match("title/kernel/rd_LVM_LV").map {|p| aug.get(p)}.should == ["vg/lv7", "vg/lv8", "vg/lv9"]*3 - end - end - - it "should remove existing values if too many" do - apply!(Puppet::Type.type(:kernel_parameter).new( - :name => "rd_LVM_LV", - :ensure => :present, - :value => ["vg/lv7"], - :target => target, - :provider => "grub" - )) - - aug_open(target, "Grub.lns") do |aug| - aug.match("title/kernel/rd_LVM_LV").size.should == 3 - aug.match("title/kernel/rd_LVM_LV[.='vg/lv1']").size.should == 0 - aug.match("title/kernel/rd_LVM_LV[.='vg/lv2']").size.should == 0 - aug.match("title/kernel/rd_LVM_LV").map {|p| aug.get(p)}.should == ["vg/lv7"]*3 - end - end - - it "should create recovery-only entries" do - apply!(Puppet::Type.type(:kernel_parameter).new( - :name => "foo", - :ensure => :present, - :bootmode => :recovery, - :target => target, - :provider => "grub" - )) - - aug_open(target, "Grub.lns") do |aug| - aug.match("title/kernel/foo").size.should == 1 - aug.match("title[2]/kernel/foo").size.should == 1 - end - end - - it "should create normal boot-only entries" do - apply!(Puppet::Type.type(:kernel_parameter).new( - :name => "foo", - :ensure => :present, - :bootmode => :normal, - :target => target, - :provider => "grub" - )) - - aug_open(target, "Grub.lns") do |aug| - aug.match("title/kernel/foo").size.should == 2 - aug.match("title[1]/kernel/foo").size.should == 1 - aug.match("title[3]/kernel/foo").size.should == 1 - end - end - end - - describe "when deleting entries" do - it "should delete entries when present on all resources" do - apply!(Puppet::Type.type(:kernel_parameter).new( - :name => "divider", - :ensure => "absent", - :target => target, - :provider => "grub" - )) - - aug_open(target, "Grub.lns") do |aug| - aug.match("title/kernel/divider").should == [] - end - end - - # rd_LVM_LV only exists on one entry in the fixture - it "should delete entries if partially present" do - apply!(Puppet::Type.type(:kernel_parameter).new( - :name => "rd_LVM_LV", - :ensure => :absent, - :target => target, - :provider => "grub" - )) - - aug_open(target, "Grub.lns") do |aug| - aug.match("title/kernel/rd_LVM_LV").size.should == 0 - end - end - end - - describe "when modifying values" do - before :each do - provider_class.any_instance.stubs(:create).never - end - - it "should change existing values" do - apply!(Puppet::Type.type(:kernel_parameter).new( - :name => "elevator", - :ensure => :present, - :value => "deadline", - :target => target, - :provider => "grub" - )) - - aug_open(target, "Grub.lns") do |aug| - aug.match("title/kernel/elevator").size.should == 3 - aug.match("title/kernel/elevator").map {|p| aug.get(p)}.should == ["deadline"]*3 - end - end - - it "should add value to entry" do - apply!(Puppet::Type.type(:kernel_parameter).new( - :name => "ro", - :ensure => :present, - :value => "foo", - :target => target, - :provider => "grub" - )) - - aug_open(target, "Grub.lns") do |aug| - aug.match("title/kernel/ro").size.should == 3 - aug.match("title/kernel/ro").map {|p| aug.get(p)}.should == ["foo"]*3 - end - end - - it "should add entries for multiple values" do - apply!(Puppet::Type.type(:kernel_parameter).new( - :name => "elevator", - :ensure => :present, - :value => ["noop", "deadline"], - :target => target, - :provider => "grub" - )) - - aug_open(target, "Grub.lns") do |aug| - aug.match("title/kernel/elevator").size.should == 6 - aug.match("title/kernel/elevator").map {|p| aug.get(p)}.should == ["noop", "deadline"]*3 - end - end - - it "should change existing values if present" do - apply!(Puppet::Type.type(:kernel_parameter).new( - :name => "root", - :ensure => :present, - :value => ["test1", "test2"], - :target => target, - :provider => "grub" - )) - - aug_open(target, "Grub.lns") do |aug| - aug.match("title/kernel/root").size.should == 6 - aug.match("title/kernel/root[.='/dev/VolGroup00/LogVol00']").size.should == 0 - aug.match("title/kernel/root").map {|p| aug.get(p)}.should == ["test1", "test2"]*3 - end - end - end - end - - context "with broken file" do - let(:tmptarget) { aug_fixture("broken") } - let(:target) { tmptarget.path } - - it "should fail to load" do - txn = apply(Puppet::Type.type(:kernel_parameter).new( - :name => "foo", - :ensure => :present, - :target => target, - :provider => "grub" - )) - - txn.any_failed?.should_not == nil - @logs.first.level.should == :err - @logs.first.message.include?(target).should == true - end - end -end diff --git a/spec/unit/puppet/provider/mailalias/augeas_spec.rb b/spec/unit/puppet/provider/mailalias/augeas_spec.rb deleted file mode 100755 index 3a0771f..0000000 --- a/spec/unit/puppet/provider/mailalias/augeas_spec.rb +++ /dev/null @@ -1,174 +0,0 @@ -#!/usr/bin/env rspec - -require 'spec_helper' - -provider_class = Puppet::Type.type(:mailalias).provider(:augeas) - -def fullquotes_supported? - # This lens breaks on Augeas 0.10.0 - Puppet::Util::Package.versioncmp(Puppet::Type.type(:mailalias).provider(:augeas).aug_version, '0.10.0') > 0 -end - -describe provider_class do - before :each do - FileTest.stubs(:exist?).returns false - FileTest.stubs(:exist?).with('/etc/aliases').returns true - end - - context "with empty file" do - let(:tmptarget) { aug_fixture("empty") } - let(:target) { tmptarget.path } - - it "should create simple new entry" do - apply!(Puppet::Type.type(:mailalias).new( - :name => "foo", - :recipient => "bar", - :target => target, - :provider => "augeas" - )) - - aug_open(target, "Aliases.lns") do |aug| - aug.get("./1/name").should == "foo" - aug.get("./1/value").should == "bar" - end - end - - it "should create new entry" do - apply!(Puppet::Type.type(:mailalias).new( - :name => "foo", - :recipient => [ "foo-a", "foo-b" ], - :target => target, - :provider => "augeas" - )) - - aug_open(target, "Aliases.lns") do |aug| - aug.get("./1/name").should == "foo" - aug.match("./1/value").size.should == 2 - aug.get("./1/value[1]").should == "foo-a" - aug.get("./1/value[2]").should == "foo-b" - end - end - - # Ticket #41 - context "when full quotes are supported", :if => fullquotes_supported? do - it "should create new entry with quotes" do - apply!(Puppet::Type.type(:mailalias).new( - :name => "users-leave", - :recipient => "| /var/lib/mailman/mail/mailman leave users", - :target => target, - :provider => "augeas" - )) - - aug_open(target, "Aliases.lns") do |aug| - aug.get("./1/name").should == "users-leave" - aug.get("./1/value").should == "\"| /var/lib/mailman/mail/mailman leave users\"" - end - end - end - end - - context "with full file" do - let(:tmptarget) { aug_fixture("full") } - let(:target) { tmptarget.path } - - it "should list instances" do - provider_class.stubs(:target).returns(target) - inst = provider_class.instances.map { |p| - { - :name => p.get(:name), - :ensure => p.get(:ensure), - :recipient => p.get(:recipient), - } - } - - inst.size.should == 3 - inst[0].should == {:name=>"mailer-daemon", :ensure=>:present, :recipient=>["postmaster"]} - inst[1].should == {:name=>"postmaster", :ensure=>:present, :recipient=>["root"]} - inst[2].should == {:name=>"test", :ensure=>:present, :recipient=>["user1", "user2"]} - end - - it "should delete entries" do - apply!(Puppet::Type.type(:mailalias).new( - :name => "mailer-daemon", - :ensure => "absent", - :target => target, - :provider => "augeas" - )) - - aug_open(target, "Aliases.lns") do |aug| - aug.match("*[name = 'mailer-daemon']").should == [] - end - end - - describe "when updating recipients" do - it "should replace a recipients" do - apply!(Puppet::Type.type(:mailalias).new( - :name => "mailer-daemon", - :recipient => [ "test" ], - :target => target, - :provider => "augeas" - )) - - aug_open(target, "Aliases.lns") do |aug| - aug.get("./1/name").should == "mailer-daemon" - aug.match("./1/value").size.should == 1 - aug.get("./1/value").should == "test" - end - end - - it "should add multiple recipients" do - apply!(Puppet::Type.type(:mailalias).new( - :name => "mailer-daemon", - :recipient => [ "test-a", "test-b" ], - :target => target, - :provider => "augeas" - )) - - aug_open(target, "Aliases.lns") do |aug| - aug.get("./1/name").should == "mailer-daemon" - aug.match("./1/value").size.should == 2 - aug.get("./1/value[1]").should == "test-a" - aug.get("./1/value[2]").should == "test-b" - end - end - - # Ticket #41 - context "when full quotes are supported", :if => fullquotes_supported? do - let(:tmptarget) { aug_fixture("fullquotes") } - let(:target) { tmptarget.path } - - it "should update entry with quotes" do - apply!(Puppet::Type.type(:mailalias).new( - :name => "users-leave", - :recipient => "| /var/lib/mailman/mail/mailman leave userss", - :target => target, - :provider => "augeas" - )) - - aug_open(target, "Aliases.lns") do |aug| - aug.get("./4/name").should == "users-leave" - aug.get("./4/value").should == "\"| /var/lib/mailman/mail/mailman leave userss\"" - end - end - end - end - end - - context "with broken file" do - let(:tmptarget) { aug_fixture("broken") } - let(:target) { tmptarget.path } - - it "should fail to load" do - txn = apply(Puppet::Type.type(:mailalias).new( - :name => "foo", - :recipient => "bar", - :target => target, - :provider => "augeas" - )) - - txn.any_failed?.should_not == nil - @logs.first.level.should == :err - @logs.first.message.include?(target).should == true - end - end -end diff --git a/spec/unit/puppet/provider/mounttab/fstab_spec.rb b/spec/unit/puppet/provider/mounttab/fstab_spec.rb deleted file mode 100755 index b045300..0000000 --- a/spec/unit/puppet/provider/mounttab/fstab_spec.rb +++ /dev/null @@ -1,406 +0,0 @@ -#!/usr/bin/env rspec - -require 'spec_helper' - -type = Puppet::Type.type(:mounttab) -unless type - raise Puppet::DevError, < 0 -end - -describe provider_class do - before :each do - Facter.stubs(:value).with(:feature).returns(nil) - Facter.stubs(:value).with(:osfamily).returns("RedHat") - Facter.stubs(:value).with(:operatingsystem).returns("Fedora") - FileTest.stubs(:exist?).returns false - FileTest.stubs(:exist?).with('/etc/fstab').returns true - end - - context "with empty file" do - let(:tmptarget) { aug_fixture("empty") } - let(:target) { tmptarget.path } - - it "should create simple new entry" do - apply!(Puppet::Type.type(:mounttab).new( - :name => "/mnt", - :device => "/dev/myvg/mytest", - :fstype => "ext4", - :options => "defaults", - :target => target, - :provider => "augeas" - )) - - aug_open(target, "Fstab.lns") do |aug| - aug.get("./1/spec").should == "/dev/myvg/mytest" - aug.get("./1/file").should == "/mnt" - aug.get("./1/vfstype").should == "ext4" - aug.match("./1/opt").size.should == 1 - aug.get("./1/opt[1]").should == "defaults" - end - end - - it "should create new entry" do - apply!(Puppet::Type.type(:mounttab).new( - :name => "/mnt", - :device => "/dev/myvg/mytest", - :fstype => "ext4", - :options => [ "nosuid", "uid=12345" ], - :dump => "1", - :pass => "2", - :target => target, - :provider => "augeas" - )) - - aug_open(target, "Fstab.lns") do |aug| - aug.get("./1/spec").should == "/dev/myvg/mytest" - aug.get("./1/file").should == "/mnt" - aug.get("./1/vfstype").should == "ext4" - aug.match("./1/opt").size.should == 2 - aug.get("./1/opt[1]").should == "nosuid" - aug.get("./1/opt[2]").should == "uid" - aug.get("./1/opt[2]/value").should == "12345" - aug.get("./1/dump").should == "1" - aug.get("./1/passno").should == "2" - end - end - - it "should create new entry without options" do - apply!(Puppet::Type.type(:mounttab).new( - :name => "/mnt", - :device => "/dev/myvg/mytest", - :fstype => "ext4", - :target => target, - :provider => "augeas" - )) - - aug_open(target, "Fstab.lns") do |aug| - aug.get("./1/spec").should == "/dev/myvg/mytest" - aug.get("./1/file").should == "/mnt" - aug.get("./1/vfstype").should == "ext4" - aug.match("./1/opt").size.should == 1 - aug.get("./1/opt[1]").should == "defaults" - end - end - end - - context "with full file" do - let(:tmptarget) { aug_fixture("full") } - let(:target) { tmptarget.path } - - it "should list instances" do - provider_class.stubs(:target).returns(target) - inst = provider_class.instances.map { |p| - r = {} - [:name,:ensure,:device,:blockdevice,:fstype,:options,:pass,:atboot,:dump].each { |pr| r[pr] = p.get(pr) } - r - } - - inst.size.should == 8 - inst[0].should == {:name=>"/", :ensure=>:present, :device=>"/dev/mapper/vgiridium-lvroot", :blockdevice=>:absent, :fstype=>"ext4", :options=>["noatime"], :pass=>:absent, :atboot=>:absent, :dump=>:absent} - inst[1].should == {:name=>"/boot", :ensure=>:present, :device=>"UUID=23b3b5f4-d5b3-4661-ad41-caa970f3ca59", :blockdevice=>:absent, :fstype=>"ext4", :options=>["noatime"], :pass=>"2", :atboot=>:absent, :dump=>"1"} - inst[2].should == {:name=>"/home", :ensure=>:present, :device=>"/dev/mapper/luks-10f63ee4-8296-434e-8de1-cde932e8a2e1", :blockdevice=>:absent, :fstype=>"ext4", :options=>["noatime"], :pass=>"2", :atboot=>:absent, :dump=>"1"} - inst[3].should == {:name=>"/tmp", :ensure=>:present, :device=>"tmpfs", :blockdevice=>:absent, :fstype=>"tmpfs", :options=>["size=1024m"], :pass=>"0", :atboot=>:absent, :dump=>"0"} - end - - it "should delete entries" do - aug_open(target, "Fstab.lns") do |aug| - aug.match("*[file = '/']").should_not == [] - end - - apply!(Puppet::Type.type(:mounttab).new( - :name => "/", - :ensure => "absent", - :target => target, - :provider => "augeas" - )) - - aug_open(target, "Fstab.lns") do |aug| - aug.match("*[file = '/']").should == [] - end - end - - it "should update device" do - apply!(Puppet::Type.type(:mounttab).new( - :name => "/home", - :device => "/dev/myvg/mytest", - :target => target, - :provider => "augeas" - )) - - aug_open(target, "Fstab.lns") do |aug| - aug.get("./3/file").should == "/home" - aug.get("./3/spec").should == "/dev/myvg/mytest" - - aug.get("./3/vfstype").should == "ext4" - aug.match("./3/opt").size.should == 1 - aug.get("./3/opt[1]").should == "noatime" - end - end - - it "should update device without changing dump or pass" do - pending "issue #16122 against mounttab type as they're changing" - - apply!(Puppet::Type.type(:mounttab).new( - :name => "/home", - :device => "/dev/myvg/mytest", - :target => target, - :provider => "augeas" - )) - - aug_open(target, "Fstab.lns") do |aug| - aug.get("./3/file").should == "/home" - aug.get("./3/spec").should == "/dev/myvg/mytest" - aug.get("./3/dump").should == "1" - aug.get("./3/passno").should == "2" - end - end - - it "should update fstype" do - apply!(Puppet::Type.type(:mounttab).new( - :name => "/home", - :fstype => "btrfs", - :target => target, - :provider => "augeas" - )) - - aug_open(target, "Fstab.lns") do |aug| - aug.get("./3/file").should == "/home" - aug.get("./3/vfstype").should == "btrfs" - - aug.get("./3/spec").should == "/dev/mapper/luks-10f63ee4-8296-434e-8de1-cde932e8a2e1" - aug.match("./3/opt").size.should == 1 - aug.get("./3/opt[1]").should == "noatime" - end - end - - describe "when updating options" do - it "should replace with one option" do - apply!(Puppet::Type.type(:mounttab).new( - :name => "/home", - :options => "nosuid", - :target => target, - :provider => "augeas" - )) - - aug_open(target, "Fstab.lns") do |aug| - aug.get("./3/file").should == "/home" - aug.match("./3/opt").size.should == 1 - aug.get("./3/opt[1]").should == "nosuid" - - aug.get("./3/spec").should == "/dev/mapper/luks-10f63ee4-8296-434e-8de1-cde932e8a2e1" - aug.get("./3/vfstype").should == "ext4" - end - end - - it "should add multiple options" do - apply!(Puppet::Type.type(:mounttab).new( - :name => "/home", - :options => ["nosuid", "nodev"], - :target => target, - :provider => "augeas" - )) - - aug_open(target, "Fstab.lns") do |aug| - aug.get("./3/file").should == "/home" - aug.match("./3/opt").size.should == 2 - aug.get("./3/opt[1]").should == "nosuid" - aug.get("./3/opt[2]").should == "nodev" - end - end - - it "should add various complex options" do - apply!(Puppet::Type.type(:mounttab).new( - :name => "/home", - :options => ["nosuid", "uid=12345", 'rootcontext="system_u:object_r:tmpfs_t:s0"'], - :target => target, - :provider => "augeas" - )) - - aug_open(target, "Fstab.lns") do |aug| - aug.get("./3/file").should == "/home" - aug.match("./3/opt").size.should == 3 - aug.get("./3/opt[1]").should == "nosuid" - aug.get("./3/opt[2]").should == "uid" - aug.get("./3/opt[2]/value").should == "12345" - aug.get("./3/opt[3]").should == "rootcontext" - aug.get("./3/opt[3]/value").should == '"system_u:object_r:tmpfs_t:s0"' - end - end - - it "should remove options" do - apply!(Puppet::Type.type(:mounttab).new( - :name => "/home", - :options => [], - :target => target, - :provider => "augeas" - )) - - aug_open(target, "Fstab.lns") do |aug| - aug.get("./3/file").should == "/home" - aug.match("./3/opt").size.should == 1 - aug.get("./3/opt[1]").should == "defaults" - end - end - - it "should leave options alone" do - apply!(Puppet::Type.type(:mounttab).new( - :name => "/home", - :target => target, - :provider => "augeas" - )) - - aug_open(target, "Fstab.lns") do |aug| - aug.get("./3/file").should == "/home" - aug.match("./3/opt").size.should == 1 - aug.get("./3/opt[1]").should == "noatime" - end - end - end - - describe "when updating dump" do - it "should add dump" do - apply!(Puppet::Type.type(:mounttab).new( - :name => "/", - :dump => 1, - :target => target, - :provider => "augeas" - )) - - aug_open(target, "Fstab.lns") do |aug| - aug.get("./1/file").should == "/" - aug.get("./1/dump").should == "1" - end - end - - context "when nooptions is supported", :if => nooptions_supported? do - let(:tmptarget) { aug_fixture("nooptions") } - let(:target) { tmptarget.path } - - it "should add options first, then dump" do - apply!(Puppet::Type.type(:mounttab).new( - :name => "swap", - :dump => 1, - :target => target, - :provider => "augeas" - )) - - aug_open(target, "Fstab.lns") do |aug| - aug.get("./5/file").should == "swap" - aug.match("./5/opt").size.should == 1 - aug.get("./5/opt[1]").should == "defaults" - aug.get("./5/dump").should == "1" - end - end - end - - it "should change dump" do - apply!(Puppet::Type.type(:mounttab).new( - :name => "/home", - :dump => 0, - :target => target, - :provider => "augeas" - )) - - aug_open(target, "Fstab.lns") do |aug| - aug.get("./3/file").should == "/home" - aug.get("./3/dump").should == "0" - end - end - end - - describe "when updating pass" do - it "should add dump and pass" do - apply!(Puppet::Type.type(:mounttab).new( - :name => "/", - :pass => 2, - :target => target, - :provider => "augeas" - )) - - aug_open(target, "Fstab.lns") do |aug| - aug.get("./1/file").should == "/" - # dump will be missing, so it also has to be added - aug.get("./1/dump").should == "0" - aug.get("./1/passno").should == "2" - end - end - - context "when nooptions is supported", :if => nooptions_supported? do - let(:tmptarget) { aug_fixture("nooptions") } - let(:target) { tmptarget.path } - - it "should add options and dump first, then pass" do - apply!(Puppet::Type.type(:mounttab).new( - :name => "swap", - :pass => 1, - :target => target, - :provider => "augeas" - )) - - aug_open(target, "Fstab.lns") do |aug| - aug.get("./5/file").should == "swap" - aug.match("./5/opt").size.should == 1 - aug.get("./5/opt[1]").should == "defaults" - aug.get("./5/dump").should == "0" - aug.get("./5/passno").should == "1" - end - end - end - - it "should change pass" do - apply!(Puppet::Type.type(:mounttab).new( - :name => "/home", - :pass => 1, - :target => target, - :provider => "augeas" - )) - - aug_open(target, "Fstab.lns") do |aug| - aug.get("./3/file").should == "/home" - aug.get("./3/passno").should == "1" - end - end - end - end - - context "with broken file" do - let(:tmptarget) { aug_fixture("broken") } - let(:target) { tmptarget.path } - - it "should fail to load" do - txn = apply(Puppet::Type.type(:mounttab).new( - :name => "/home", - :device => "LABEL=home", - :target => target, - :provider => "augeas" - )) - - txn.any_failed?.should_not == nil - @logs.first.level.should == :err - @logs.first.message.include?(target).should == true - end - end -end diff --git a/spec/unit/puppet/provider/mounttab/vfstab_spec.rb b/spec/unit/puppet/provider/mounttab/vfstab_spec.rb deleted file mode 100644 index a39c6d4..0000000 --- a/spec/unit/puppet/provider/mounttab/vfstab_spec.rb +++ /dev/null @@ -1,377 +0,0 @@ -#!/usr/bin/env rspec - -require 'spec_helper' - -provider_class = Puppet::Type.type(:mounttab).provider(:augeas) -def valid_lens? - # This lens breaks on Augeas 0.10.0 - Puppet::Util::Package.versioncmp(Puppet::Type.type(:mailalias).provider(:augeas).aug_version, '0.10.0') > 0 -end - -describe provider_class, :if => valid_lens? do - before :each do - Facter.stubs(:value).with(:feature).returns(nil) - Facter.stubs(:value).with(:osfamily).returns("Solaris") - Facter.stubs(:value).with(:operatingsystem).returns("Solaris") - FileTest.stubs(:exist?).returns false - FileTest.stubs(:exist?).with('/etc/fstab').returns true - FileTest.stubs(:exist?).with('/etc/vfstab').returns true - end - - context "with empty vfstab file" do - let(:tmptarget) { aug_fixture("empty") } - let(:target) { tmptarget.path } - - it "should create simple new entry" do - apply!(Puppet::Type.type(:mounttab).new( - :name => "/foo", - :device => "/dev/dsk/c1t1d1s1", - :fstype => "ufs", - :atboot => "yes", - :target => target, - :provider => "augeas" - )) - - augparse(target, "Vfstab.lns", ' - { "1" - { "spec" = "/dev/dsk/c1t1d1s1" } - { "fsck" = "/dev/rdsk/c1t1d1s1" } - { "file" = "/foo" } - { "vfstype" = "ufs" } - { "atboot" = "yes" } - } - ') - end - - it "should create new entry" do - apply!(Puppet::Type.type(:mounttab).new( - :name => "/foo", - :device => "/dev/dsk/c1t1d1s1", - :blockdevice => "/dev/foo/c1t1d1s1", - :fstype => "ufs", - :pass => "2", - :atboot => "yes", - :options => [ "nosuid", "nodev" ], - :target => target, - :provider => "augeas" - )) - - augparse(target, "Vfstab.lns", ' - { "1" - { "spec" = "/dev/dsk/c1t1d1s1" } - { "fsck" = "/dev/foo/c1t1d1s1" } - { "file" = "/foo" } - { "vfstype" = "ufs" } - { "passno" = "2" } - { "atboot" = "yes" } - { "opt" = "nosuid" } - { "opt" = "nodev" } - } - ') - end - end - - context "with full vfstab file" do - let(:tmptarget) { aug_fixture("full") } - let(:target) { tmptarget.path } - - it "should list instances" do - provider_class.stubs(:target).returns(target) - inst = provider_class.instances.map { |p| - r = {} - [:name,:ensure,:device,:blockdevice,:fstype,:options,:pass,:atboot,:dump].each { |pr| r[pr] = p.get(pr) } - r - } - - inst.size.should == 6 - inst[0].should == {:name=>"/dev/fd", :ensure=>:present, :device=>"fd", :blockdevice=>"-", :fstype=>"fd", :options=>"-", :pass=>"-", :atboot=>"no", :dump=>:absent} - inst[1].should == {:name=>"/proc", :ensure=>:present, :device=>"/proc", :blockdevice=>"-", :fstype=>"proc", :options=>"-", :pass=>"-", :atboot=>"no", :dump=>:absent} - inst[2].should == {:name=>"-", :ensure=>:present, :device=>"/dev/dsk/c0t0d0s1", :blockdevice=>"-", :fstype=>"swap", :options=>"-", :pass=>"-", :atboot=>"no", :dump=>:absent} - inst[3].should == {:name=>"/", :ensure=>:present, :device=>"/dev/dsk/c0t0d0s0", :blockdevice=>"/dev/rdsk/c0t0d0s0", :fstype=>"ufs", :options=>"-", :pass=>"1", :atboot=>"no", :dump=>:absent} - inst[5].should == {:name=>"/tmp", :ensure=>:present, :device=>"swap", :blockdevice=>"-", :fstype=>"tmpfs", :options=>["size=1024m"], :pass=>"-", :atboot=>"yes", :dump=>:absent} - end - - it "should delete entries" do - aug_open(target, "Vfstab.lns") do |aug| - aug.match("*[file = '/']").should_not == [] - end - - apply!(Puppet::Type.type(:mounttab).new( - :name => "/", - :ensure => "absent", - :target => target, - :provider => "augeas" - )) - - aug_open(target, "Vfstab.lns") do |aug| - aug.match("*[file = '/']").should == [] - end - end - - it "should update device" do - apply!(Puppet::Type.type(:mounttab).new( - :name => "/", - :device => "/dev/dsk/c1t1d1s1", - :target => target, - :provider => "augeas" - )) - - # fsck will get updated implicitly, due to the type - # passno gets removed due to issue #16122 against mounttab - # atboot will get changed, also #16122 - augparse_filter(target, "Vfstab.lns", "*[file='/']", ' - { "1" - { "spec" = "/dev/dsk/c1t1d1s1" } - { "fsck" = "/dev/rdsk/c1t1d1s1" } - { "file" = "/" } - { "vfstype" = "ufs" } - { "atboot" = "yes" } - } - ') - end - - it "should update fstype" do - apply!(Puppet::Type.type(:mounttab).new( - :name => "/", - :fstype => "zfs", - :target => target, - :provider => "augeas" - )) - - # passno gets removed due to issue #16122 against mounttab - # atboot will get changed, also #16122 - augparse_filter(target, "Vfstab.lns", "*[file='/']", ' - { "1" - { "spec" = "/dev/dsk/c0t0d0s0" } - { "fsck" = "/dev/rdsk/c0t0d0s0" } - { "file" = "/" } - { "vfstype" = "zfs" } - { "atboot" = "yes" } - } - ') - end - - describe "when updating options" do - it "should replace with one option" do - apply!(Puppet::Type.type(:mounttab).new( - :name => "/tmp", - :options => "nosuid", - :target => target, - :provider => "augeas" - )) - - augparse_filter(target, "Vfstab.lns", "*[file='/tmp']", ' - { "1" - { "spec" = "swap" } - { "file" = "/tmp" } - { "vfstype" = "tmpfs" } - { "atboot" = "yes" } - { "opt" = "nosuid" } - } - ') - end - - it "should add multiple options" do - apply!(Puppet::Type.type(:mounttab).new( - :name => "/tmp", - :options => ["nosuid", "nodev"], - :target => target, - :provider => "augeas" - )) - - augparse_filter(target, "Vfstab.lns", "*[file='/tmp']", ' - { "1" - { "spec" = "swap" } - { "file" = "/tmp" } - { "vfstype" = "tmpfs" } - { "atboot" = "yes" } - { "opt" = "nosuid" } - { "opt" = "nodev" } - } - ') - end - - it "should remove options" do - apply!(Puppet::Type.type(:mounttab).new( - :name => "/tmp", - :options => [], - :target => target, - :provider => "augeas" - )) - - augparse_filter(target, "Vfstab.lns", "*[file='/tmp']", ' - { "1" - { "spec" = "swap" } - { "file" = "/tmp" } - { "vfstype" = "tmpfs" } - { "atboot" = "yes" } - } - ') - end - - it "should leave options alone" do - pending "issue #16122 against mounttab type as they're being removed" - - apply!(Puppet::Type.type(:mounttab).new( - :name => "/tmp", - :target => target, - :provider => "augeas" - )) - - augparse_filter(target, "Vfstab.lns", "*[file='/tmp']", ' - { "1" - { "spec" = "swap" } - { "file" = "/tmp" } - { "vfstype" = "tmpfs" } - { "atboot" = "yes" } - { "opt" = "size" - { "value" = "1024m" } } - } - ') - end - end - - describe "when updating blockdevice" do - it "should add blockdevice" do - apply!(Puppet::Type.type(:mounttab).new( - :name => "/tmp", - :blockdevice => "/dev/tofsck", - :target => target, - :provider => "augeas" - )) - - augparse_filter(target, "Vfstab.lns", "*[file='/tmp']", ' - { "1" - { "spec" = "swap" } - { "fsck" = "/dev/tofsck" } - { "file" = "/tmp" } - { "vfstype" = "tmpfs" } - { "atboot" = "yes" } - } - ') - end - - it "should change blockdevice" do - apply!(Puppet::Type.type(:mounttab).new( - :name => "/", - :blockdevice => "/dev/foo/c0t0d0s0", - :target => target, - :provider => "augeas" - )) - - # passno gets removed due to issue #16122 against mounttab - # atboot will get changed, also #16122 - augparse_filter(target, "Vfstab.lns", "*[file='/']", ' - { "1" - { "spec" = "/dev/dsk/c0t0d0s0" } - { "fsck" = "/dev/foo/c0t0d0s0" } - { "file" = "/" } - { "vfstype" = "ufs" } - { "atboot" = "yes" } - } - ') - end - - it "should remove blockdevice" do - apply!(Puppet::Type.type(:mounttab).new( - :name => "/fsck", - :blockdevice => "-", - :target => target, - :provider => "augeas" - )) - - # passno gets removed due to issue #16122 against mounttab - # atboot will get changed, also #16122 - augparse_filter(target, "Vfstab.lns", "*[file='/fsck']", ' - { "1" - { "spec" = "mydev" } - { "file" = "/fsck" } - { "vfstype" = "ufs" } - { "atboot" = "yes" } - } - ') - end - end - - describe "when updating atboot" do - it "should change atboot" do - apply!(Puppet::Type.type(:mounttab).new( - :name => "/dev/fd", - :atboot => "yes", - :target => target, - :provider => "augeas" - )) - - augparse_filter(target, "Vfstab.lns", "*[file='/dev/fd']", ' - { "1" - { "spec" = "fd" } - { "file" = "/dev/fd" } - { "vfstype" = "fd" } - { "atboot" = "yes" } - } - ') - end - end - - describe "when updating pass" do - it "should add pass" do - apply!(Puppet::Type.type(:mounttab).new( - :name => "/dev/fd", - :pass => 2, - :target => target, - :provider => "augeas" - )) - - # atboot will get changed, also #16122 - augparse_filter(target, "Vfstab.lns", "*[file='/dev/fd']", ' - { "1" - { "spec" = "fd" } - { "file" = "/dev/fd" } - { "vfstype" = "fd" } - { "passno" = "2" } - { "atboot" = "yes" } - } - ') - end - - it "should change pass" do - apply!(Puppet::Type.type(:mounttab).new( - :name => "/", - :pass => 7, - :target => target, - :provider => "augeas" - )) - - # atboot will get changed, also #16122 - augparse_filter(target, "Vfstab.lns", "*[file='/']", ' - { "1" - { "spec" = "/dev/dsk/c0t0d0s0" } - { "fsck" = "/dev/rdsk/c0t0d0s0" } - { "file" = "/" } - { "vfstype" = "ufs" } - { "passno" = "7" } - { "atboot" = "yes" } - } - ') - end - end - end - - context "with broken vfstab file" do - let(:tmptarget) { aug_fixture("broken") } - let(:target) { tmptarget.path } - - it "should fail to load" do - txn = apply(Puppet::Type.type(:mounttab).new( - :name => "/", - :device => "/dev/dsk/c0t0d1s0", - :target => target, - :provider => "augeas" - )) - - txn.any_failed?.should_not == nil - @logs.first.level.should == :err - @logs.first.message.include?(target).should == true - end - end -end diff --git a/spec/unit/puppet/provider/nrpe_command/augeas_spec.rb b/spec/unit/puppet/provider/nrpe_command/augeas_spec.rb deleted file mode 100755 index caa1f02..0000000 --- a/spec/unit/puppet/provider/nrpe_command/augeas_spec.rb +++ /dev/null @@ -1,113 +0,0 @@ -#!/usr/bin/env rspec - -require 'spec_helper' - -provider_class = Puppet::Type.type(:nrpe_command).provider(:augeas) - -describe provider_class do - context "with empty file" do - let(:tmptarget) { aug_fixture("empty") } - let(:target) { tmptarget.path } - - it "should create new entry" do - apply!(Puppet::Type.type(:nrpe_command).new( - :name => "check_spec_test", - :command => "/usr/bin/check_my_thing -p 'some command with \"multiple [types]\" of quotes' -x and-stuff", - :target => target, - :provider => "augeas" - )) - - augparse(target, "Nrpe.lns", ' - { "command" - { "check_spec_test" = "/usr/bin/check_my_thing -p \'some command with \"multiple [types]\" of quotes\' -x and-stuff" } - } - ') - end - - end - - context "with full file" do - let(:tmptarget) { aug_fixture("full") } - let(:target) { tmptarget.path } - - it "should list instances" do - provider_class.stubs(:target).returns(target) - inst = provider_class.instances.map { |p| - { - :name => p.get(:name), - :ensure => p.get(:ensure), - :command => p.get(:command), - } - } - - inst.size.should == 6 - inst[0].should == {:name=>"check_users", :ensure=>:present, :command=>"/usr/lib/nagios/plugins/check_users -w 5 -c 10" } - inst[1].should == {:name=>"check_load", :ensure=>:present, :command=>"/usr/lib/nagios/plugins/check_load -w 15,10,5 -c 30,25,20" } - inst[2].should == {:name=>"check_hda1", :ensure=>:present, :command=>"/usr/lib/nagios/plugins/check_disk -w 20% -c 10% -p /dev/hda1" } - inst[3].should == {:name=>"check_zombie_procs", :ensure=>:present, :command=>"/usr/lib/nagios/plugins/check_procs -w 5 -c 10 -s Z" } - inst[4].should == {:name=>"check_total_procs", :ensure=>:present, :command=>"/usr/lib/nagios/plugins/check_procs -w 150 -c 200 " } - inst[5].should == {:name=>"check_test", :ensure=>:present, :command=>"/usr/lib/nagios/plugins/check_http -I 127.0.0.1 -p 8080 -u /ubrowse.action?acro=SCGC-ENS" } - end - - it "should delete entries" do - apply!(Puppet::Type.type(:nrpe_command).new( - :name => "check_test", - :ensure => "absent", - :target => target, - :provider => "augeas" - )) - - aug_open(target, "Nrpe.lns") do |aug| - aug.match("command/check_test").size.should == 0 - end - end - - it "should update value" do - apply!(Puppet::Type.type(:nrpe_command).new( - :name => "check_users", - :command => "/usr/lib/nagios/plugins/check_users -w 10 -c 20", - :target => target, - :provider => "augeas" - )) - - augparse_filter(target, "Nrpe.lns", "command[check_users]", ' - { "command" - { "check_users" = "/usr/lib/nagios/plugins/check_users -w 10 -c 20" } - } - ') - end - - it "should create new entry" do - apply!(Puppet::Type.type(:nrpe_command).new( - :name => "check_spec_test", - :command => "/usr/bin/check_my_thing -p 'some command with \"multiple [types]\" of quotes' -x and-stuff", - :target => target, - :provider => "augeas" - )) - - augparse_filter(target, "Nrpe.lns", "command[check_spec_test]", ' - { "command" - { "check_spec_test" = "/usr/bin/check_my_thing -p \'some command with \"multiple [types]\" of quotes\' -x and-stuff" } - } - ') - end - end - - context "with broken file" do - let(:tmptarget) { aug_fixture("broken") } - let(:target) { tmptarget.path } - - it "should fail to load" do - txn = apply(Puppet::Type.type(:nrpe_command).new( - :name => "check_this", - :command => "/usr/bin/mycheck -w this", - :target => target, - :provider => "augeas" - )) - - txn.any_failed?.should_not == nil - @logs.first.level.should == :err - @logs.first.message.include?(target).should == true - end - end -end diff --git a/spec/unit/puppet/provider/pam/augeas_spec.rb b/spec/unit/puppet/provider/pam/augeas_spec.rb deleted file mode 100755 index 1221b36..0000000 --- a/spec/unit/puppet/provider/pam/augeas_spec.rb +++ /dev/null @@ -1,190 +0,0 @@ -#!/usr/bin/env rspec - -require 'spec_helper' - -provider_class = Puppet::Type.type(:pam).provider(:augeas) - -describe provider_class do - before :each do - FileTest.stubs(:exist?).returns false - end - - context "with empty file" do - let(:tmptarget) { aug_fixture("empty") } - let(:target) { tmptarget.path } - - it "should create simple new entry" do - apply!(Puppet::Type.type(:pam).new( - :title => "Add pam_test.so to auth for system-auth", - :service => "system-auth", - :type => "auth", - :control => "sufficient", - :module => "pam_test.so", - :arguments => "test_me_out", - :position => "before module pam_deny.so", - :target => target, - :provider => "augeas", - :ensure => "present" - )) - - aug_open(target, "Pam.lns") do |aug| - aug.get("./1/module").should == "pam_test.so" - aug.get("./1/argument[1]").should == "test_me_out" - end - end - end - - context "with full file" do - let(:tmptarget) { aug_fixture("full") } - let(:target) { tmptarget.path } - - it "should list instances" do - provider_class.stubs(:target).returns(target) - inst = provider_class.instances.map { |p| - { - :ensure => p.get(:ensure), - :service => p.get(:service), - :type => p.get(:type), - :control => p.get(:control), - :module => p.get(:module), - :arguments => p.get(:arguments), - } - } - - inst.size.should == 21 - inst[0].should == {:ensure => :present, - :service => :absent, - :type => "auth", - :control => "required", - :module => "pam_env.so", - :arguments => [],} - inst[1].should == {:ensure => :present, - :service => :absent, - :type => "auth", - :control => "sufficient", - :module => "pam_unix.so", - :arguments => ["nullok","try_first_pass"],} - inst[5].should == {:ensure => :present, - :service => :absent, - :type => "account", - :control => "required", - :module => "pam_unix.so", - :arguments => ["broken_shadow"],} - inst[8].should == {:ensure => :present, - :service => :absent, - :type => "account", - :control => "[default=bad success=ok user_unknown=ignore]", - :module => "pam_sss.so", - :arguments => [],} - inst[10].should == {:ensure => :present, - :service => :absent, - :type => "password", - :control => "requisite", - :module => "pam_pwquality.so", - :arguments => ["try_first_pass","retry=3","type="],} - end - - describe "when creating settings" do - it "should create simple new entry" do - apply!(Puppet::Type.type(:pam).new( - :title => "Add pam_test.so to auth for system-auth", - :service => "system-auth", - :type => "auth", - :control => "sufficient", - :module => "pam_test.so", - :arguments => "test_me_out", - :position => "before module pam_deny.so", - :target => target, - :provider => "augeas", - :ensure => "present" - )) - - aug_open(target, "Pam.lns") do |aug| - aug.get("./5/module").should == "pam_test.so" - aug.get("./5/argument[1]").should == "test_me_out" - end - end - end - - describe "when modifying settings" do - it "Changing the number of retries" do - apply!(Puppet::Type.type(:pam).new( - :title => "Set retry count for pwquality", - :service => "system-auth", - :type => "password", - :control => "requisite", - :module => "pam_pwquality.so", - :arguments => ["try_first_pass","retry=4","type="], - :target => target, - :provider => "augeas", - :ensure => "present" - )) - - aug_open(target, "Pam.lns") do |aug| - aug.match('./*[type="password" and module="pam_pwquality.so" and argument="retry=4"]').size.should == 1 - end - end - - it "should remove the type= argument" do - apply!(Puppet::Type.type(:pam).new( - :title => "Remove type= from pwquality check", - :service => "system-auth", - :type => "password", - :control => "requisite", - :module => "pam_pwquality.so", - :arguments => ["try_first_pass","retry=4"], - :target => target, - :provider => "augeas", - :ensure => "present" - )) - - aug_open(target, "Pam.lns") do |aug| - aug.match('./*[type="password" and module="pam_pwquality.so" and argument="type="]').size.should == 0 - end - end - end - - describe "when removing settings" do - it "should remove the entry" do - apply!(Puppet::Type.type(:pam).new( - :title => "Remove pwquality entry", - :service => "system-auth", - :type => "password", - :control => "requisite", - :module => "pam_pwquality.so", - :arguments => ["try_first_pass","retry=4"], - :target => target, - :provider => "augeas", - :ensure => "absent" - )) - - aug_open(target, "Pam.lns") do |aug| - aug.match('./*[type="password" and module="pam_pwquality.so"]').size.should == 0 - end - end - end - end - - context "with broken file" do - let(:tmptarget) { aug_fixture("broken") } - let(:target) { tmptarget.path } - - it "should fail to load" do - txn = apply(Puppet::Type.type(:pam).new( - :title => "Ensure pwquality is configured", - :service => "system-auth", - :type => "password", - :control => "requisite", - :module => "pam_pwquality.so", - :arguments => ["try_first_pass","retry=3","type="], - :target => target, - :provider => "augeas", - :ensure => "present" - )) - - txn.any_failed?.should_not == nil - @logs.first.level.should == :err - @logs.first.message.include?(target).should == true - end - end -end diff --git a/spec/unit/puppet/provider/pg_hba/augeas_spec.rb b/spec/unit/puppet/provider/pg_hba/augeas_spec.rb deleted file mode 100644 index 062ad9f..0000000 --- a/spec/unit/puppet/provider/pg_hba/augeas_spec.rb +++ /dev/null @@ -1,524 +0,0 @@ -#!/usr/bin/env rspec - -require 'spec_helper' - -provider_class = Puppet::Type.type(:pg_hba).provider(:augeas) -def valid_lens? - # This lens breaks on Augeas 0.10.0 - Puppet::Util::Package.versioncmp(Puppet::Type.type(:mailalias).provider(:augeas).aug_version, '0.10.0') > 0 -end - -RSpec.configure do |c| - c.filter_run_excluding :composite => false -end - -if Puppet.version =~ /^0\./ - composite_supported = false -else - composite_supported = true -end - -describe provider_class, :if => valid_lens? do - context "when composite namevars are supported", :composite => composite_supported do - before(:all) { @tmpdir = Dir.mktmpdir } - after(:all) { FileUtils.remove_entry_secure @tmpdir } - - context "with no existing file" do - let(:target) { File.join(@tmpdir, "new_file") } - - it "should create simple new local entry" do - apply!(Puppet::Type.type(:pg_hba).new( - :name => "local to all on all", - :method => "md5", - :target => target, - :provider => "augeas" - )) - - augparse(target, "Pg_hba.lns", ' - { "1" - { "type" = "local" } - { "database" = "all" } - { "user" = "all" } - { "method" = "md5" } - } - ') - end - end - - context "with empty file" do - let(:tmptarget) { aug_fixture("empty") } - let(:target) { tmptarget.path } - - it "should create simple new local entry" do - apply!(Puppet::Type.type(:pg_hba).new( - :name => "local to all on all", - :method => "md5", - :target => target, - :provider => "augeas" - )) - - augparse(target, "Pg_hba.lns", ' - { "1" - { "type" = "local" } - { "database" = "all" } - { "user" = "all" } - { "method" = "md5" } - } - ') - end - - context 'when specifying target in namevar' do - it "should create simple new local entry" do - apply!(Puppet::Type.type(:pg_hba).new( - :name => "local to all on all in #{target}", - :method => "md5", - :provider => "augeas" - )) - - augparse(target, "Pg_hba.lns", ' - { "1" - { "type" = "local" } - { "database" = "all" } - { "user" = "all" } - { "method" = "md5" } - } - ') - end - end - - it "should create simple new local entry with random namevar and using default" do - apply!(Puppet::Type.type(:pg_hba).new( - :name => "A local entry", - :method => "md5", - :target => target, - :provider => "augeas" - )) - - augparse(target, "Pg_hba.lns", ' - { "1" - { "type" = "local" } - { "database" = "all" } - { "user" = "all" } - { "method" = "md5" } - } - ') - end - - it "should create simple new local entry with options" do - apply!(Puppet::Type.type(:pg_hba).new( - :name => "local to all on all", - :method => "ident", - :options => { - 'sameuser' => :undef, - 'krb_realm' => 'EXAMPLE.COM', - 'ldapsuffix' => ',ou=people,dc=example,dc=com', - }, - :target => target, - :provider => "augeas" - )) - - # Options can be in various orders (hash) - aug_open(target, "Pg_hba.lns") do |aug| - aug.match("*/method/option[.='sameuser']").size.should == 1 - aug.match("*/method/option[.='krb_realm' and value='EXAMPLE.COM']").size.should == 1 - aug.match("*/method/option[.='ldapsuffix' and value=',ou=people,dc=example,dc=com']").size.should == 1 - end - end - - it "should create simple new host entry" do - apply!(Puppet::Type.type(:pg_hba).new( - :name => "host to all on all from 1.2.3.4", - :method => "md5", - :target => target, - :provider => "augeas" - )) - - augparse(target, "Pg_hba.lns", ' - { "1" - { "type" = "host" } - { "database" = "all" } - { "user" = "all" } - { "address" = "1.2.3.4" } - { "method" = "md5" } - } - ') - end - - it "should create new local entry with multiple users and databases" do - apply!(Puppet::Type.type(:pg_hba).new( - :name => "local to +titi,@toto on db1,db2", - :method => "md5", - :target => target, - :provider => "augeas" - )) - - augparse(target, "Pg_hba.lns", ' - { "1" - { "type" = "local" } - { "database" = "db1" } - { "database" = "db2" } - { "user" = "+titi" } - { "user" = "@toto" } - { "method" = "md5" } - } - ') - end - - it "should create new local entry with multiple users and databases using personalized namevar" do - apply!(Puppet::Type.type(:pg_hba).new( - :name => "+titi and @toto on db1 and db2", - :user => ['+titi', '@toto'], - :database => ['db1', 'db2'], - :method => "md5", - :target => target, - :provider => "augeas" - )) - - augparse(target, "Pg_hba.lns", ' - { "1" - { "type" = "local" } - { "database" = "db1" } - { "database" = "db2" } - { "user" = "+titi" } - { "user" = "@toto" } - { "method" = "md5" } - } - ') - end - end - - context "with full file" do - let(:tmptarget) { aug_fixture("full") } - let(:target) { tmptarget.path } - - it "should create new entry" do - apply!(Puppet::Type.type(:pg_hba).new( - :name => "local to all on mydb", - :method => "md5", - :target => target, - :provider => "augeas" - )) - - augparse_filter(target, "Pg_hba.lns", "*[database='mydb']", ' - { "1" - { "type" = "local" } - { "database" = "mydb" } - { "user" = "all" } - { "method" = "md5" } - } - ') - end - - it "should create new entry after first entry" do - apply!(Puppet::Type.type(:pg_hba).new( - :name => "local to all on mydb", - :position => "after *[type][1]", - :method => "md5", - :target => target, - :provider => "augeas" - )) - - augparse_filter(target, "Pg_hba.lns", "./2", ' - { "1" - { "type" = "local" } - { "database" = "mydb" } - { "user" = "all" } - { "method" = "md5" } - } - ') - end - - it "should create new entry before first entry" do - apply!(Puppet::Type.type(:pg_hba).new( - :name => "local to all on mydb", - :position => "before *[type][1]", - :method => "md5", - :target => target, - :provider => "augeas" - )) - - augparse_filter(target, "Pg_hba.lns", "./1", ' - { "1" - { "type" = "local" } - { "database" = "mydb" } - { "user" = "all" } - { "method" = "md5" } - } - ') - end - - it "should create new entry before first entry using shortcut" do - apply!(Puppet::Type.type(:pg_hba).new( - :name => "local to all on mydb", - :position => "before first entry", - :method => "md5", - :target => target, - :provider => "augeas" - )) - - augparse_filter(target, "Pg_hba.lns", "./1", ' - { "1" - { "type" = "local" } - { "database" = "mydb" } - { "user" = "all" } - { "method" = "md5" } - } - ') - end - - it "should create new entry before last entry using shortcut" do - apply!(Puppet::Type.type(:pg_hba).new( - :name => "local to all on mydb", - :position => "before last entry", - :method => "md5", - :target => target, - :provider => "augeas" - )) - - augparse_filter(target, "Pg_hba.lns", "./16", ' - { "1" - { "type" = "local" } - { "database" = "mydb" } - { "user" = "all" } - { "method" = "md5" } - } - ') - end - - it "should create new entry after first host using shortcut" do - apply!(Puppet::Type.type(:pg_hba).new( - :name => "local to all on mydb", - :position => "after first host", - :method => "md5", - :target => target, - :provider => "augeas" - )) - - augparse_filter(target, "Pg_hba.lns", "./3", ' - { "1" - { "type" = "local" } - { "database" = "mydb" } - { "user" = "all" } - { "method" = "md5" } - } - ') - end - - it "should create new entry before last anyhost using shortcut" do - apply!(Puppet::Type.type(:pg_hba).new( - :name => "local to all on mydb", - :position => "before last anyhost", - :method => "md5", - :target => target, - :provider => "augeas" - )) - - augparse_filter(target, "Pg_hba.lns", "./11", ' - { "1" - { "type" = "local" } - { "database" = "mydb" } - { "user" = "all" } - { "method" = "md5" } - } - ') - end - - it "should delete local entry" do - apply!(Puppet::Type.type(:pg_hba).new( - :name => "local to all on all", - :ensure => "absent", - :target => target, - :provider => "augeas" - )) - - aug_open(target, "Pg_hba.lns") do |aug| - aug.match("*[type='local' and user='all' and database='all']").should == [] - end - end - - it "should update value of local entry" do - apply!(Puppet::Type.type(:pg_hba).new( - :name => "local to all on all", - :method => "bar", - :target => target, - :provider => "augeas" - )) - - augparse_filter(target, "Pg_hba.lns", "*[type='local' and user='all' and database='all']", ' - { "1" - { "type" = "local" } - { "database" = "all" } - { "user" = "all" } - { "method" = "bar" } - } - ') - end - - it "should update value of local entry with options" do - apply!(Puppet::Type.type(:pg_hba).new( - :name => "local to all on all", - :method => "ident", - :options => { - 'sameuser' => :undef, - }, - :target => target, - :provider => "augeas" - )) - - augparse_filter(target, "Pg_hba.lns", "*[type='local' and user='all' and database='all']", ' - { "1" - { "type" = "local" } - { "database" = "all" } - { "user" = "all" } - { "method" = "ident" - { "option" = "sameuser" } } - } - ') - end - - it "should move first entry after last entry" do - apply!(Puppet::Type.type(:pg_hba).new( - :name => "local to all on all", - :ensure => "positioned", - :method => "trust", - :position => "after last entry", - :target => target, - :provider => "augeas" - )) - - augparse_filter(target, "Pg_hba.lns", "./16", ' - { "1" - { "type" = "local" } - { "database" = "all" } - { "user" = "all" } - { "method" = "trust" } - } - ') - end - - it "should move entry before first host" do - apply!(Puppet::Type.type(:pg_hba).new( - :name => "local to sameuser on all", - :ensure => "positioned", - :method => "md5", - :position => "before first host", - :target => target, - :provider => "augeas" - )) - - augparse_filter(target, "Pg_hba.lns", "./2", ' - { "1" - { "type" = "local" } - { "database" = "all" } - { "user" = "sameuser" } - { "method" = "md5" } - } - ') - end - - it "should create simple new host entry" do - apply!(Puppet::Type.type(:pg_hba).new( - :name => "host to all on all from 1.2.3.4", - :method => "md5", - :target => target, - :provider => "augeas" - )) - - augparse_filter(target, "Pg_hba.lns", "*[type='host' and user='all' and database='all' and address='1.2.3.4']", ' - { "1" - { "type" = "host" } - { "database" = "all" } - { "user" = "all" } - { "address" = "1.2.3.4" } - { "method" = "md5" } - } - ') - end - - it "should delete host entry" do - apply!(Puppet::Type.type(:pg_hba).new( - :name => "host to all on all from 127.0.0.1/32", - :ensure => "absent", - :target => target, - :provider => "augeas" - )) - - aug_open(target, "Pg_hba.lns") do |aug| - aug.match("*[type='host' and user='all' and database='all' and address='127.0.0.1/32']").should == [] - end - end - - it "should update value of host entry" do - apply!(Puppet::Type.type(:pg_hba).new( - :name => "host to all on all from 127.0.0.1/32", - :method => "md5", - :target => target, - :provider => "augeas" - )) - - augparse_filter(target, "Pg_hba.lns", "*[type='host' and user='all' and database='all' and address='127.0.0.1/32']", ' - { "1" - { "type" = "host" } - { "database" = "all" } - { "user" = "all" } - { "address" = "127.0.0.1/32" } - { "method" = "md5" } - } - ') - end - - it "should update value of host entry with options" do - apply!(Puppet::Type.type(:pg_hba).new( - :name => "host to all on all from 192.168.0.0/16", - :method => "ident", - :options => { - 'sameuser' => :undef, - 'map' => 'omicron', - }, - :target => target, - :provider => "augeas" - )) - - aug_open(target, "Pg_hba.lns") do |aug| - aug.match("*[address='192.168.0.0/16']/method/option[.='sameuser']").size.should == 1 - aug.match("*[address='192.168.0.0/16']/method/option[.='map' and value='omicron']").size.should == 1 - end - end - - it "should update value of host entry with options removed" do - apply!(Puppet::Type.type(:pg_hba).new( - :name => "host to all on all from 192.168.0.0/16", - :method => "ident", - :options => { - 'sameuser' => :undef, - }, - :target => target, - :provider => "augeas" - )) - - aug_open(target, "Pg_hba.lns") do |aug| - aug.match("*[address='192.168.0.0/16']/method/option[.='sameuser']").size.should == 1 - aug.match("*[address='192.168.0.0/16']/method/option[.='map' and value='omicron']").size.should == 0 - end - end - end - - context "with broken file" do - let(:tmptarget) { aug_fixture("broken") } - let(:target) { tmptarget.path } - - it "should fail to load" do - txn = apply(Puppet::Type.type(:pg_hba).new( - :name => "local to all on all", - :method => "md5", - :target => target, - :provider => "augeas" - )) - - txn.any_failed?.should_not == nil - @logs.first.level.should == :err - @logs.first.message.include?(target).should == true - end - end - end -end diff --git a/spec/unit/puppet/provider/puppet_auth/augeas_spec.rb b/spec/unit/puppet/provider/puppet_auth/augeas_spec.rb deleted file mode 100644 index e71c4a0..0000000 --- a/spec/unit/puppet/provider/puppet_auth/augeas_spec.rb +++ /dev/null @@ -1,178 +0,0 @@ -#!/usr/bin/env rspec - -require 'spec_helper' - -provider_class = Puppet::Type.type(:puppet_auth).provider(:augeas) -def valid_lens? - # This lens breaks on Augeas 0.10.0 - Puppet::Util::Package.versioncmp(Puppet::Type.type(:mailalias).provider(:augeas).aug_version, '0.10.0') > 0 -end - -describe provider_class, :if => valid_lens? do - before :each do - FileTest.stubs(:exist?).returns false - FileTest.stubs(:exist?).with('/etc/puppet/auth.conf').returns true - end - - context "with empty file" do - let(:tmptarget) { aug_fixture("empty") } - let(:target) { tmptarget.path } - - it "should create simple new entry" do - apply!(Puppet::Type.type(:puppet_auth).new( - :name => "/facts rule", - :path => "/facts", - :authenticated => "any", - :target => target, - :provider => "augeas", - :ensure => "present" - )) - - aug_open(target, "Puppet_Auth.lns") do |aug| - aug.match("path").size.should == 1 - aug.get("path").should == "/facts" - aug.match("path/operator").size.should == 0 - aug.get("path/auth").should == "any" - end - end - end - - context "with full file" do - let(:tmptarget) { aug_fixture("full") } - let(:target) { tmptarget.path } - - it "should list instances" do - provider_class.stubs(:target).returns(target) - inst = provider_class.instances.map { |p| - { - :name => p.get(:name), - :ensure => p.get(:ensure), - :path => p.get(:path), - :path_regex => p.get(:path_regex), - :environments => p.get(:environments), - :methods => p.get(:methods), - :allow => p.get(:allow), - :allow_ip => p.get(:allow_ip), - :authenticated => p.get(:authenticated), - } - } - - inst.size.should == 9 - inst[0].should == {:path_regex=>:true, :methods=>["find"], :environments=>[], :authenticated=>:absent, :allow=>["$1"], :allow_ip=>[], :ensure=>:present, :name=>"Auth rule matching ^/catalog/([^/]+)$", :path=>"^/catalog/([^/]+)$"} - inst[2].should == {:path_regex=>:false, :methods=>["find"], :environments=>[], :authenticated=>:absent, :allow=>["*"], :allow_ip=>[], :ensure=>:present, :name=>"Auth rule for /certificate_revocation_list/ca", :path=>"/certificate_revocation_list/ca"} - inst[7].should == {:path_regex=>:false, :methods=>["find", "save"], :environments=>[], :authenticated=>"any", :allow=>["*"], :allow_ip=>[], :ensure=>:present, :name=>"Auth rule for /certificate_request", :path=>"/certificate_request"} - end - - describe "when creating settings" do - it "should create a simple new entry" do - apply!(Puppet::Type.type(:puppet_auth).new( - :name => "/facts before first deny", - :path => "/facts", - :environments => ["staging", "stable"], - :methods => "find", - :authenticated => "any", - :ins_before => "first deny", - :target => target, - :provider => "augeas", - :ensure => "present" - )) - - aug_open(target, "Puppet_Auth.lns") do |aug| - aug.get("path[last()-1]").should == "/facts" - aug.get("path[.='/facts']/environment/1").should == "staging" - aug.match("path[.='/facts']/method/*").size.should == 1 - aug.get("path[.='/facts']/method/1").should == "find" - end - end - - it "should create an entry with a regex path" do - apply!(Puppet::Type.type(:puppet_auth).new( - :name => "Matching ^/foo/([^/]+)$", - :path => "^/foo/([^/]+)$", - :path_regex => "true", - :authenticated => "any", - :target => target, - :provider => "augeas", - :ensure => "present" - )) - - aug_open(target, "Puppet_Auth.lns") do |aug| - aug.get("path[.='^/foo/([^/]+)$']/operator").should == '~' - end - end - end - - describe "when modifying settings" do - it "should modify the properties" do - apply!(Puppet::Type.type(:puppet_auth).new( - :name => "Apply /certificate/ to staging", - :path => "/certificate/", - :environments => "staging", - :authenticated => "on", - :allow => ["localhost.localdomain", "example.com"], - :allow_ip => "192.168.0.1/32", - :target => target, - :provider => "augeas", - :ensure => "present" - )) - - aug_open(target, "Puppet_Auth.lns") do |aug| - aug.get("path[.='/certificate/']/environment/1").should == "staging" - aug.get("path[.='/certificate/']/auth").should == "on" - aug.get("path[.='/certificate/']/allow/1").should == "localhost.localdomain" - aug.get("path[.='/certificate/']/allow/2").should == "example.com" - aug.get("path[.='/certificate/']/allow_ip/1").should == "192.168.0.1/32" - end - end - - it "should remove the save method" do - apply!(Puppet::Type.type(:puppet_auth).new( - :name => "Remove save method from /certificate_request", - :path => "/certificate_request", - :methods => "find", - :target => target, - :provider => "augeas", - :ensure => "present" - )) - - aug_open(target, "Puppet_Auth.lns") do |aug| - aug.match("path[.='/certificate_request']/method").size.should == 1 - aug.get("path[.='/certificate_request']/method/1").should == "find" - end - end - - it "should remove the entry" do - apply!(Puppet::Type.type(:puppet_auth).new( - :name => "Remove save method from /certificate_request", - :path => "/certificate_request", - :target => target, - :provider => "augeas", - :ensure => "absent" - )) - - aug_open(target, "Puppet_Auth.lns") do |aug| - aug.match("path[.='/certificate_request']").size.should == 0 - end - end - end - end - - context "with broken file" do - let(:tmptarget) { aug_fixture("broken") } - let(:target) { tmptarget.path } - - it "should fail to load" do - txn = apply(Puppet::Type.type(:puppet_auth).new( - :name => "Test broken", - :path => "/facts", - :target => target, - :provider => "augeas", - :ensure => "present" - )) - - txn.any_failed?.should_not == nil - @logs.first.level.should == :err - @logs.first.message.include?(target).should == true - end - end -end diff --git a/spec/unit/puppet/provider/shellvar/augeas_spec.rb b/spec/unit/puppet/provider/shellvar/augeas_spec.rb deleted file mode 100755 index 0836cf7..0000000 --- a/spec/unit/puppet/provider/shellvar/augeas_spec.rb +++ /dev/null @@ -1,585 +0,0 @@ -#!/usr/bin/env rspec - -require 'spec_helper' - -provider_class = Puppet::Type.type(:shellvar).provider(:augeas) - -describe provider_class do - let(:unset_seq?) { subject.unset_seq? } - - context "with empty file" do - let(:tmptarget) { aug_fixture("empty") } - let(:target) { tmptarget.path } - - it "should create simple new entry" do - apply!(Puppet::Type.type(:shellvar).new( - :variable => "ENABLE", - :value => "true", - :target => target, - :provider => "augeas" - )) - - augparse(target, "Shellvars.lns", ' - { "ENABLE" = "true" } - ') - end - - it "should create new entry with multiple values as string" do - apply!(Puppet::Type.type(:shellvar).new( - :variable => "PORTS", - :value => ["123", "456", 789], - :array_type => "string", - :target => target, - :provider => "augeas" - )) - - augparse(target, "Shellvars.lns", ' - { "PORTS" = "\"123 456 789\"" } - ') - end - - it "should create new entry with multiple values as array" do - apply!(Puppet::Type.type(:shellvar).new( - :variable => "PORTS", - :value => ["123", "456", "789"], - :array_type => "array", - :target => target, - :provider => "augeas" - )) - - augparse(target, "Shellvars.lns", ' - { "PORTS" - { "1" = "123" } - { "2" = "456" } - { "3" = "789" } } - ') - end - - it "should create new entry with comment" do - apply!(Puppet::Type.type(:shellvar).new( - :variable => "ENABLE", - :value => "true", - :comment => "test", - :target => target, - :provider => "augeas" - )) - - augparse(target, "Shellvars.lns", ' - { "#comment" = "ENABLE: test" } - { "ENABLE" = "true" } - ') - end - - it "should create new entry as unset" do - apply!(Puppet::Type.type(:shellvar).new( - :ensure => "unset", - :variable => "ENABLE", - :target => target, - :provider => "augeas" - )) - - if unset_seq? - augparse(target, "Shellvars.lns", ' - { "@unset" { "1" = "ENABLE" } } - ') - else - augparse(target, "Shellvars.lns", ' - { "@unset" = "ENABLE" } - ') - end - end - - it "should create new entry as unset with comment" do - apply!(Puppet::Type.type(:shellvar).new( - :ensure => "unset", - :variable => "ENABLE", - :comment => "test", - :target => target, - :provider => "augeas" - )) - - if unset_seq? - augparse(target, "Shellvars.lns", ' - { "#comment" = "ENABLE: test" } - { "@unset" { "1" = "ENABLE" } } - ') - else - augparse(target, "Shellvars.lns", ' - { "#comment" = "ENABLE: test" } - { "@unset" = "ENABLE" } - ') - end - end - - it "should create new entry as exported" do - apply!(Puppet::Type.type(:shellvar).new( - :ensure => "exported", - :variable => "ENABLE", - :value => "true", - :target => target, - :provider => "augeas" - )) - - augparse(target, "Shellvars.lns", ' - { "ENABLE" = "true" { "export" } } - ') - end - end - - context "with full file" do - let(:tmptarget) { aug_fixture("full") } - let(:target) { tmptarget.path } - - it "should create new entry next to commented out entry" do - apply!(Puppet::Type.type(:shellvar).new( - :variable => "SYNC_HWCLOCK", - :value => "yes", - :target => target, - :provider => "augeas" - )) - - if unset_seq? - augparse_filter(target, "Shellvars.lns", '*[preceding-sibling::#comment[.=~regexp(".*sync hw clock.*")]]', ' - { "#comment" = "SYNC_HWCLOCK=no" } - { "SYNC_HWCLOCK" = "yes" } - { "EXAMPLE" = "foo" } - { "@unset" { "1" = "EXAMPLE_U" } } - { "EXAMPLE_E" = "baz" { "export" } } - { "STR_LIST" = "\"foo bar baz\"" } - { "LST_LIST" - { "1" = "foo" } - { "2" = "\"bar baz\"" } - { "3" = "123" } - } - ') - else - augparse_filter(target, "Shellvars.lns", '*[preceding-sibling::#comment[.=~regexp(".*sync hw clock.*")]]', ' - { "#comment" = "SYNC_HWCLOCK=no" } - { "SYNC_HWCLOCK" = "yes" } - { "EXAMPLE" = "foo" } - { "@unset" = "EXAMPLE_U" } - { "EXAMPLE_E" = "baz" { "export" } } - { "STR_LIST" = "\"foo bar baz\"" } - { "LST_LIST" - { "1" = "foo" } - { "2" = "\"bar baz\"" } - { "3" = "123" } - } - ') - end - end - - it "should replace comment with new entry" do - apply!(Puppet::Type.type(:shellvar).new( - :variable => "SYNC_HWCLOCK", - :value => "yes", - :uncomment => true, - :target => target, - :provider => "augeas" - )) - - if unset_seq? - augparse_filter(target, "Shellvars.lns", '*[preceding-sibling::#comment[.=~regexp(".*sync hw clock.*")]]', ' - { "SYNC_HWCLOCK" = "yes" } - { "EXAMPLE" = "foo" } - { "@unset" { "1" = "EXAMPLE_U" } } - { "EXAMPLE_E" = "baz" { "export" } } - { "STR_LIST" = "\"foo bar baz\"" } - { "LST_LIST" - { "1" = "foo" } - { "2" = "\"bar baz\"" } - { "3" = "123" } - } - ') - else - augparse_filter(target, "Shellvars.lns", '*[preceding-sibling::#comment[.=~regexp(".*sync hw clock.*")]]', ' - { "SYNC_HWCLOCK" = "yes" } - { "EXAMPLE" = "foo" } - { "@unset" = "EXAMPLE_U" } - { "EXAMPLE_E" = "baz" { "export" } } - { "STR_LIST" = "\"foo bar baz\"" } - { "LST_LIST" - { "1" = "foo" } - { "2" = "\"bar baz\"" } - { "3" = "123" } - } - ') - end - end - - it "should delete entries" do - apply!(Puppet::Type.type(:shellvar).new( - :variable => "RETRIES", - :ensure => "absent", - :target => target, - :provider => "augeas" - )) - - aug_open(target, "Shellvars.lns") do |aug| - aug.match("RETRIES").should == [] - aug.match("#comment[. =~ regexp('RETRIES:.*')]").should == [] - end - end - - it "should delete unset entries" do - apply!(Puppet::Type.type(:shellvar).new( - :variable => "EXAMPLE_U", - :ensure => "absent", - :target => target, - :provider => "augeas" - )) - - aug_open(target, "Shellvars.lns") do |aug| - aug.match("EXAMPLE_U").should == [] - if unset_seq? - aug.match("@unset[*='EXAMPLE_U']").should == [] - else - aug.match("@unset[.='EXAMPLE_U']").should == [] - end - end - end - - describe "when updating value" do - it "should change unquoted value" do - apply!(Puppet::Type.type(:shellvar).new( - :variable => "RETRIES", - :value => "1", - :target => target, - :provider => "augeas" - )) - - augparse_filter(target, "Shellvars.lns", "RETRIES", ' - { "RETRIES" = "1" } - ') - end - - it "should change quoted value" do - apply!(Puppet::Type.type(:shellvar).new( - :variable => "OPTIONS", - :value => "-p 3 -s", - :target => target, - :provider => "augeas" - )) - - augparse_filter(target, "Shellvars.lns", "OPTIONS", ' - { "OPTIONS" = "\"-p 3 -s\"" } - ') - end - - it "should leave single quotes as-is" do - apply!(Puppet::Type.type(:shellvar).new( - :variable => "OPTIONS_SINGLE", - :value => "3", - :target => target, - :provider => "augeas" - )) - - augparse_filter(target, "Shellvars.lns", "OPTIONS_SINGLE", ' - { "OPTIONS_SINGLE" = "\'3\'" } - ') - end - - it "should leave double quotes as-is" do - apply!(Puppet::Type.type(:shellvar).new( - :variable => "OPTIONS", - :value => "3", - :target => target, - :provider => "augeas" - )) - - augparse_filter(target, "Shellvars.lns", "OPTIONS", ' - { "OPTIONS" = "\"3\"" } - ') - end - - it "should automatically add quotes" do - apply!(Puppet::Type.type(:shellvar).new( - :variable => "RETRIES", - :value => "-p 3 -s", - :target => target, - :provider => "augeas" - )) - - augparse_filter(target, "Shellvars.lns", "RETRIES", ' - { "RETRIES" = "\"-p 3 -s\"" } - ') - end - - it "should add forced single quotes" do - apply!(Puppet::Type.type(:shellvar).new( - :variable => "RETRIES", - :value => "3", - :quoted => "single", - :target => target, - :provider => "augeas" - )) - - augparse_filter(target, "Shellvars.lns", "RETRIES", ' - { "RETRIES" = "\'3\'" } - ') - end - - it "should add forced double quotes" do - apply!(Puppet::Type.type(:shellvar).new( - :variable => "RETRIES", - :value => "3", - :quoted => "double", - :target => target, - :provider => "augeas" - )) - - augparse_filter(target, "Shellvars.lns", "RETRIES", ' - { "RETRIES" = "\"3\"" } - ') - end - - it "should error when removing necessary quotes" do - txn = apply(Puppet::Type.type(:shellvar).new( - :variable => "OPTIONS", - :value => "-p 3", - :quoted => "false", - :target => target, - :provider => "augeas" - )) - - txn.any_failed?.should_not == nil - logs_num = Puppet::Util::Package.versioncmp(Puppet.version, '3.4.0') >= 0 ? 1 : 0 - @logs[logs_num].level.should == :err - @logs[logs_num].message.include?('Failed to save').should == true - end - - it "should update string array value as auto string" do - apply!(Puppet::Type.type(:shellvar).new( - :variable => "STR_LIST", - :value => ["foo", "baz"], - :array_type => 'auto', - :target => target, - :provider => "augeas" - )) - - augparse_filter(target, "Shellvars.lns", "STR_LIST", ' - { "STR_LIST" = "\"foo baz\"" } - ') - end - - it "should update string array value as array" do - apply!(Puppet::Type.type(:shellvar).new( - :variable => "STR_LIST", - :value => ["foo", "baz"], - :array_type => 'array', - :target => target, - :provider => "augeas" - )) - - augparse_filter(target, "Shellvars.lns", "STR_LIST", ' - { "STR_LIST" - { "1" = "foo" } - { "2" = "baz" } } - ') - end - - it "should update array array value as auto array" do - apply!(Puppet::Type.type(:shellvar).new( - :variable => "LST_LIST", - :value => ["foo", "baz"], - :array_type => 'auto', - :target => target, - :provider => "augeas" - )) - - augparse_filter(target, "Shellvars.lns", "LST_LIST", ' - { "LST_LIST" - { "1" = "foo" } - { "2" = "baz" } } - ') - end - - it "should update array array value as string" do - apply!(Puppet::Type.type(:shellvar).new( - :variable => "LST_LIST", - :value => ["foo", "baz"], - :array_type => 'string', - :target => target, - :provider => "augeas" - )) - - augparse_filter(target, "Shellvars.lns", "LST_LIST", ' - { "LST_LIST" = "\"foo baz\"" } - ') - end - end - - describe "when using array_append" do - it "should not remove existing values" do - apply!(Puppet::Type.type(:shellvar).new( - :variable => "STR_LIST", - :value => ["foo", "fooz"], - :array_append => true, - :target => target, - :provider => "augeas" - )) - - augparse_filter(target, "Shellvars.lns", "STR_LIST", ' - { "STR_LIST" = "\"foo bar baz fooz\"" } - ') - end - end - - describe "when updating comment" do - it "should add comment" do - apply!(Puppet::Type.type(:shellvar).new( - :variable => "OPTIONS", - :comment => "test comment", - :target => target, - :provider => "augeas" - )) - - augparse_filter(target, "Shellvars.lns", '*[following-sibling::OPTIONS]', ' - { "#comment" = "OPTIONS: test comment" } - ') - end - - it "should change comment" do - apply!(Puppet::Type.type(:shellvar).new( - :variable => "RETRIES", - :comment => "Never gonna give you up", - :target => target, - :provider => "augeas" - )) - - aug_open(target, "Shellvars.lns") do |aug| - aug.match("#comment[. = 'retry setting']").should_not == [] - aug.match("#comment[. = 'RETRIES: Never gonna give you up']").should_not == [] - end - end - - it "should remove comment" do - apply!(Puppet::Type.type(:shellvar).new( - :variable => "RETRIES", - :comment => "", - :target => target, - :provider => "augeas" - )) - - aug_open(target, "Shellvars.lns") do |aug| - aug.match("#comment[. =~ regexp('RETRIES:.*')]").should == [] - aug.match("#comment[. = 'retry setting']").should_not == [] - end - end - end - - it "should set value as unset" do - apply!(Puppet::Type.type(:shellvar).new( - :ensure => "unset", - :variable => "EXAMPLE", - :target => target, - :provider => "augeas" - )) - - aug_open(target, "Shellvars.lns") do |aug| - aug.match("EXAMPLE").should == [] - aug.match("@unset").size.should == 2 - end - end - - it "should set value as unset from exported" do - apply!(Puppet::Type.type(:shellvar).new( - :ensure => "unset", - :variable => "EXAMPLE_E", - :target => target, - :provider => "augeas" - )) - - aug_open(target, "Shellvars.lns") do |aug| - aug.match("EXAMPLE_E").should == [] - aug.match("@unset").size.should == 2 - end - end - - it "should set value as exported" do - apply!(Puppet::Type.type(:shellvar).new( - :ensure => "exported", - :variable => "EXAMPLE", - :value => "foo", - :target => target, - :provider => "augeas" - )) - - aug_open(target, "Shellvars.lns") do |aug| - aug.match("EXAMPLE/export").should_not == [] - end - end - - it "should set value as exported from unset" do - apply!(Puppet::Type.type(:shellvar).new( - :ensure => "exported", - :variable => "EXAMPLE_U", - :value => "foo", - :target => target, - :provider => "augeas" - )) - - aug_open(target, "Shellvars.lns") do |aug| - if unset_seq? - aug.match("@unset[*='EXAMPLE_U']").should == [] - else - aug.match("@unset[.='EXAMPLE_U']").should == [] - end - aug.match("EXAMPLE_U/export").should_not == [] - end - end - - it "should un-unset value" do - apply!(Puppet::Type.type(:shellvar).new( - :ensure => "present", - :variable => "EXAMPLE_U", - :value => "foo", - :target => target, - :provider => "augeas" - )) - - aug_open(target, "Shellvars.lns") do |aug| - if unset_seq? - aug.match("@unset[*='EXAMPLE_U']").should == [] - else - aug.match("@unset[.='EXAMPLE_U']").should == [] - end - aug.match("EXAMPLE_U/export").should == [] - aug.get("EXAMPLE_U").should == 'foo' - end - end - - it "should un-export value" do - apply!(Puppet::Type.type(:shellvar).new( - :ensure => "present", - :variable => "EXAMPLE_E", - :value => "foo", - :target => target, - :provider => "augeas" - )) - - aug_open(target, "Shellvars.lns") do |aug| - aug.match("EXAMPLE_E/export").should == [] - aug.get("EXAMPLE_E").should == 'foo' - end - end - end - - context "with broken file" do - let(:tmptarget) { aug_fixture("broken") } - let(:target) { tmptarget.path } - - it "should fail to load" do - txn = apply(Puppet::Type.type(:shellvar).new( - :variable => "RETRIES", - :value => "1", - :target => target, - :provider => "augeas" - )) - - txn.any_failed?.should_not == nil - @logs.first.level.should == :err - @logs.first.message.include?(target).should == true - end - end -end diff --git a/spec/unit/puppet/provider/sshd_config/augeas_spec.rb b/spec/unit/puppet/provider/sshd_config/augeas_spec.rb deleted file mode 100755 index e22eec0..0000000 --- a/spec/unit/puppet/provider/sshd_config/augeas_spec.rb +++ /dev/null @@ -1,522 +0,0 @@ -#!/usr/bin/env rspec - -require 'spec_helper' - -provider_class = Puppet::Type.type(:sshd_config).provider(:augeas) - -describe provider_class do - before :each do - FileTest.stubs(:exist?).returns false - FileTest.stubs(:exist?).with('/etc/ssh/sshd_config').returns true - end - - context "with empty file" do - let(:tmptarget) { aug_fixture("empty") } - let(:target) { tmptarget.path } - - it "should create simple new entry" do - apply!(Puppet::Type.type(:sshd_config).new( - :name => "PermitRootLogin", - :value => "yes", - :target => target, - :provider => "augeas" - )) - - aug_open(target, "Sshd.lns") do |aug| - aug.get("PermitRootLogin").should == "yes" - end - end - - it "should create an array entry" do - apply!(Puppet::Type.type(:sshd_config).new( - :name => "AllowGroups", - :value => ["sshgroups", "admins"], - :target => target, - :provider => "augeas" - )) - - aug_open(target, "Sshd.lns") do |aug| - aug.get("AllowGroups/1").should == "sshgroups" - aug.get("AllowGroups/2").should == "admins" - end - end - - it "should create new entry in a Match block" do - apply!(Puppet::Type.type(:sshd_config).new( - :name => "X11Forwarding", - :condition => "Host foo User root", - :value => "yes", - :target => target, - :provider => "augeas" - )) - - aug_open(target, "Sshd.lns") do |aug| - aug.get("Match[1]/Condition/Host").should == "foo" - aug.get("Match[1]/Condition/User").should == "root" - aug.get("Match[1]/Settings/X11Forwarding").should == "yes" - end - end - - context "when declaring two resources with same key" do - it "should fail with same name" do - expect do - apply!( - Puppet::Type.type(:sshd_config).new( - :name => "X11Forwarding", - :value => "no", - :target => target, - :provider => "augeas" - ), - Puppet::Type.type(:sshd_config).new( - :name => "X11Forwarding", - :condition => "Host foo User root", - :value => "yes", - :target => target, - :provider => "augeas" - ) - ) - end.to raise_error(Puppet::Resource::Catalog::DuplicateResourceError) - end - - it "should fail with different names, same key and no conditions" do - expect do - apply!( - Puppet::Type.type(:sshd_config).new( - :name => "X11Forwarding", - :value => "no", - :target => target, - :provider => "augeas" - ), - Puppet::Type.type(:sshd_config).new( - :name => "Global X11Forwarding", - :key => "X11Forwarding", - :value => "yes", - :target => target, - :provider => "augeas" - ) - ) - end.to raise_error - end - - it "should not fail with different names, same key and different conditions" do - expect do - apply!( - Puppet::Type.type(:sshd_config).new( - :name => "X11Forwarding", - :value => "no", - :target => target, - :provider => "augeas" - ), - Puppet::Type.type(:sshd_config).new( - :name => "Global X11Forwarding", - :key => "X11Forwarding", - :condition => "User foo", - :value => "yes", - :target => target, - :provider => "augeas" - ) - ) - end.not_to raise_error - end - end - end - - context "with full file" do - let(:tmptarget) { aug_fixture("full") } - let(:target) { tmptarget.path } - - it "should list instances" do - provider_class.stubs(:target).returns(target) - inst = provider_class.instances.map { |p| - { - :name => p.get(:name), - :ensure => p.get(:ensure), - :value => p.get(:value), - :condition => p.get(:condition), - } - } - - inst.size.should == 17 - inst[0].should == {:name=>"ListenAddress", :ensure=>:present, :value=>["0.0.0.0", "::"], :condition=>:absent} - inst[1].should == {:name=>"SyslogFacility", :ensure=>:present, :value=>["AUTHPRIV"], :condition=>:absent} - inst[2].should == {:name=>"AllowGroups", :ensure=>:present, :value=>["sshusers", "admins"], :condition=>:absent} - inst[3].should == {:name=>"PermitRootLogin", :ensure=>:present, :value=>["without-password"], :condition=>:absent} - inst[4].should == {:name=>"PasswordAuthentication", :ensure=>:present, :value=>["yes"], :condition=>:absent} - inst[8].should == {:name=>"UsePAM", :ensure=>:present, :value=>["yes"], :condition=>:absent} - inst[9].should == {:name=>"AcceptEnv", :ensure=>:present, :value=>["LANG", "LC_CTYPE", "LC_NUMERIC", "LC_TIME", "LC_COLLATE", "LC_MONETARY", "LC_MESSAGES", "LC_PAPER", "LC_NAME", "LC_ADDRESS", "LC_TELEPHONE", "LC_MEASUREMENT", "LC_IDENTIFICATION", "LC_ALL", "LANGUAGE", "XMODIFIERS"], :condition=>:absent} - inst[12].should == {:name=>"X11Forwarding", :ensure=>:present, :value=>["no"], :condition=> "User anoncvs"} - inst[15].should == {:name=>"AllowAgentForwarding", :ensure=>:present, :value=>["no"], :condition=> "Host *.example.net User *"} - end - - describe "when creating settings" do - it "should add it before Match block" do - apply!(Puppet::Type.type(:sshd_config).new( - :name => "Banner", - :value => "/etc/issue", - :target => target, - :provider => "augeas" - )) - - aug_open(target, "Sshd.lns") do |aug| - aug.get("Banner").should == "/etc/issue" - end - end - - it "should insert Port before the first ListenAddress in a Match block" do - apply!(Puppet::Type.type(:sshd_config).new( - :name => "Port", - :condition => "Host *.example.net User *", - :value => "2222", - :target => target, - :provider => "augeas" - )) - - aug_open(target, "Sshd.lns") do |aug| - aug.match("Match[2]/Settings/ListenAddress[preceding-sibling::Port]").size.should == 1 - end - end - - it "should add it next to commented out entry" do - apply!(Puppet::Type.type(:sshd_config).new( - :name => "Banner", - :value => "/etc/issue", - :target => target, - :provider => "augeas" - )) - - augparse_filter(target, "Sshd.lns", '*[preceding-sibling::#comment[.="no default banner path"]][label()!="Match"]', ' - { "#comment" = "Banner none" } - { "Banner" = "/etc/issue" } - { "#comment" = "override default of no subsystems" } - { "Subsystem" - { "sftp" = "/usr/libexec/openssh/sftp-server" } } - { "#comment" = "Example of overriding settings on a per-user basis" } - ') - end - - it "should create an array entry" do - apply!(Puppet::Type.type(:sshd_config).new( - :name => "AllowUsers", - :value => ["ssh", "foo"], - :target => target, - :provider => "augeas" - )) - - aug_open(target, "Sshd.lns") do |aug| - aug.get("AllowUsers/1").should == "ssh" - aug.get("AllowUsers/2").should == "foo" - end - end - - it "should match the entire Match conditions and create new block" do - apply!(Puppet::Type.type(:sshd_config).new( - :name => "AllowAgentForwarding", - :condition => "Host *.example.net", - :value => "yes", - :target => target, - :provider => "augeas" - )) - - aug_open(target, "Sshd.lns") do |aug| - aug.get("Match[3]/Settings/AllowAgentForwarding").should == "yes" - end - end - end - - describe "when deleting settings" do - it "should delete a setting" do - expr = "PermitRootLogin" - aug_open(target, "Sshd.lns") do |aug| - aug.match(expr).should_not == [] - end - - apply!(Puppet::Type.type(:sshd_config).new( - :name => "PermitRootLogin", - :ensure => "absent", - :target => target, - :provider => "augeas" - )) - - aug_open(target, "Sshd.lns") do |aug| - aug.match(expr).should == [] - end - end - - it "should delete all instances of a setting" do - expr = "ListenAddress" - aug_open(target, "Sshd.lns") do |aug| - aug.match(expr).should_not == [] - end - - apply!(Puppet::Type.type(:sshd_config).new( - :name => "ListenAddress", - :ensure => "absent", - :target => target, - :provider => "augeas" - )) - - aug_open(target, "Sshd.lns") do |aug| - aug.match(expr).should == [] - end - end - - it "should delete from a Match block" do - expr = "Match[*]/Settings/AllowAgentForwarding" - aug_open(target, "Sshd.lns") do |aug| - aug.match(expr).should_not == [] - end - - apply!(Puppet::Type.type(:sshd_config).new( - :name => "AllowAgentForwarding", - :condition => "Host *.example.net User *", - :ensure => "absent", - :target => target, - :provider => "augeas" - )) - - aug_open(target, "Sshd.lns") do |aug| - aug.match(expr).should == [] - end - end - end - - describe "when updating settings" do - it "should replace a setting" do - apply!(Puppet::Type.type(:sshd_config).new( - :name => "PermitRootLogin", - :value => "yes", - :target => target, - :provider => "augeas" - )) - - aug_open(target, "Sshd.lns") do |aug| - aug.match("*[label()='PermitRootLogin']").size.should == 1 - aug.get("PermitRootLogin").should == "yes" - end - end - - it "should replace a setting in a Match block" do - apply!(Puppet::Type.type(:sshd_config).new( - :name => "X11Forwarding", - :condition => "User anoncvs", - :value => "yes", - :target => target, - :provider => "augeas" - )) - - aug_open(target, "Sshd.lns") do |aug| - aug.get("Match[*]/Settings/X11Forwarding").should == "yes" - end - end - - it "should replace the array setting" do - apply!(Puppet::Type.type(:sshd_config).new( - :name => "AcceptEnv", - :value => ["BAR", "LC_FOO"], - :target => target, - :provider => "augeas" - )) - - aug_open(target, "Sshd.lns") do |aug| - aug.match("AcceptEnv/*").size.should == 2 - aug.get("AcceptEnv/1").should == "BAR" - aug.get("AcceptEnv/2").should == "LC_FOO" - end - end - - it "should replace and add to multiple single-value settings" do - apply!(Puppet::Type.type(:sshd_config).new( - :name => "ListenAddress", - :value => ["192.168.1.1", "192.168.2.1", "192.168.3.1"], - :target => target, - :provider => "augeas" - )) - - aug_open(target, "Sshd.lns") do |aug| - aug.match("ListenAddress").size.should == 3 - aug.get("ListenAddress[1]").should == "192.168.1.1" - aug.get("ListenAddress[2]").should == "192.168.2.1" - aug.get("ListenAddress[3]").should == "192.168.3.1" - end - end - - it "should replace multiple single-value settings with one" do - apply!(Puppet::Type.type(:sshd_config).new( - :name => "ListenAddress", - :value => "192.168.1.1", - :target => target, - :provider => "augeas" - )) - - aug_open(target, "Sshd.lns") do |aug| - aug.match("ListenAddress").size.should == 1 - aug.get("ListenAddress").should == "192.168.1.1" - end - end - - it "should replace settings case insensitively when on Augeas >= 1.0.0", :if => provider_class.supported?(:regexpi) do - apply!(Puppet::Type.type(:sshd_config).new( - :name => "PaSswordaUtheNticAtion", - :value => "no", - :target => target, - :provider => "augeas" - )) - - aug_open(target, "Sshd.lns") do |aug| - aug.match("*[label()=~regexp('PasswordAuthentication', 'i')]").size.should == 1 - aug.get("PasswordAuthentication").should == "no" - end - end - - it "should not replace settings case insensitively when on Augeas < 1.0.0" do - provider_class.stubs(:supported?).with(:post_resource_eval) - provider_class.stubs(:supported?).with(:regexpi).returns(false) - apply!(Puppet::Type.type(:sshd_config).new( - :name => "GSSAPIauthentIcAtion", - :value => "no", - :target => target, - :provider => "augeas" - )) - - aug_open(target, "Sshd.lns") do |aug| - aug.match("GSSAPIAuthentication").size.should == 1 - aug.match("GSSAPIauthentIcAtion").size.should == 1 - aug.get("GSSAPIAuthentication").should == "yes" - aug.get("GSSAPIauthentIcAtion").should == "no" - end - end - end - end - - context "with no Match block file" do - let(:tmptarget) { aug_fixture("nomatch") } - let(:target) { tmptarget.path } - - describe "when creating settings" do - it "should replace multiple single-value settings" do - apply!(Puppet::Type.type(:sshd_config).new( - :name => "ListenAddress", - :value => ["192.168.1.1", "192.168.2.1", "192.168.3.1"], - :target => target, - :provider => "augeas" - )) - - aug_open(target, "Sshd.lns") do |aug| - aug.match("ListenAddress").size.should == 3 - aug.get("ListenAddress[1]").should == "192.168.1.1" - aug.get("ListenAddress[2]").should == "192.168.2.1" - aug.get("ListenAddress[3]").should == "192.168.3.1" - end - end - - it "should replace the array setting" do - apply!(Puppet::Type.type(:sshd_config).new( - :name => "AcceptEnv", - :value => ["BAR", "LC_FOO"], - :target => target, - :provider => "augeas" - )) - - aug_open(target, "Sshd.lns") do |aug| - aug.match("AcceptEnv/*").size.should == 2 - aug.get("AcceptEnv/1").should == "BAR" - aug.get("AcceptEnv/2").should == "LC_FOO" - end - end - - it "should replace and add to multiple single-value settings" do - apply!(Puppet::Type.type(:sshd_config).new( - :name => "ListenAddress", - :value => ["192.168.1.1", "192.168.2.1", "192.168.3.1"], - :target => target, - :provider => "augeas" - )) - - aug_open(target, "Sshd.lns") do |aug| - aug.match("ListenAddress").size.should == 3 - aug.get("ListenAddress[1]").should == "192.168.1.1" - aug.get("ListenAddress[2]").should == "192.168.2.1" - aug.get("ListenAddress[3]").should == "192.168.3.1" - end - end - - it "should replace multiple single-value settings with one" do - apply!(Puppet::Type.type(:sshd_config).new( - :name => "ListenAddress", - :value => "192.168.1.1", - :target => target, - :provider => "augeas" - )) - - aug_open(target, "Sshd.lns") do |aug| - aug.match("ListenAddress").size.should == 1 - aug.get("ListenAddress").should == "192.168.1.1" - end - end - - it "should add it next to commented out entry" do - apply!(Puppet::Type.type(:sshd_config).new( - :name => "Banner", - :value => "/etc/issue", - :target => target, - :provider => "augeas" - )) - - augparse_filter(target, "Sshd.lns", '*[preceding-sibling::#comment[.="no default banner path"]]', ' - { "#comment" = "Banner none" } - { "Banner" = "/etc/issue" } - { "#comment" = "override default of no subsystems" } - { "Subsystem" - { "sftp" = "/usr/libexec/openssh/sftp-server" } } - ') - end - - it "should insert Port before the first ListenAddress" do - apply!(Puppet::Type.type(:sshd_config).new( - :name => "Port", - :value => "2222", - :target => target, - :provider => "augeas" - )) - - aug_open(target, "Sshd.lns") do |aug| - aug.match("ListenAddress[preceding-sibling::Port]").size.should == 2 - end - end - end - - describe "when updating settings" do - it "should replace a setting" do - apply!(Puppet::Type.type(:sshd_config).new( - :name => "PermitRootLogin", - :value => "yes", - :target => target, - :provider => "augeas" - )) - - aug_open(target, "Sshd.lns") do |aug| - aug.match("*[label()='PermitRootLogin']").size.should == 1 - aug.get("PermitRootLogin").should == "yes" - end - end - end - end - - context "with broken file" do - let(:tmptarget) { aug_fixture("broken") } - let(:target) { tmptarget.path } - - it "should fail to load" do - txn = apply(Puppet::Type.type(:sshd_config).new( - :name => "PermitRootLogin", - :value => "yes", - :target => target, - :provider => "augeas" - )) - - txn.any_failed?.should_not == nil - @logs.first.level.should == :err - @logs.first.message.include?(target).should == true - end - end -end diff --git a/spec/unit/puppet/provider/sshd_config_subsystem/augeas_spec.rb b/spec/unit/puppet/provider/sshd_config_subsystem/augeas_spec.rb deleted file mode 100755 index 14cfc6b..0000000 --- a/spec/unit/puppet/provider/sshd_config_subsystem/augeas_spec.rb +++ /dev/null @@ -1,118 +0,0 @@ -#!/usr/bin/env rspec - -require 'spec_helper' - -provider_class = Puppet::Type.type(:sshd_config_subsystem).provider(:augeas) - -describe provider_class do - before :each do - FileTest.stubs(:exist?).returns false - FileTest.stubs(:exist?).with('/etc/ssh/sshd_config').returns true - end - - context "with empty file" do - let(:tmptarget) { aug_fixture("empty") } - let(:target) { tmptarget.path } - - it "should create simple new entry" do - apply!(Puppet::Type.type(:sshd_config_subsystem).new( - :name => "sftp", - :command => "/usr/lib/openssh/sftp-server", - :target => target, - :provider => "augeas" - )) - - aug_open(target, "Sshd.lns") do |aug| - aug.get("Subsystem/sftp").should == "/usr/lib/openssh/sftp-server" - end - end - end - - context "with full file" do - let(:tmptarget) { aug_fixture("full") } - let(:target) { tmptarget.path } - - it "should list instances" do - provider_class.stubs(:target).returns(target) - inst = provider_class.instances.map { |p| - { - :name => p.get(:name), - :ensure => p.get(:ensure), - :command => p.get(:command), - } - } - - inst.size.should == 1 - inst[0].should == {:name=>"sftp", :ensure=>:present, - :command=>"/usr/libexec/openssh/sftp-server"} - end - - describe "when creating settings" do - it "should add it before Match block" do - apply!(Puppet::Type.type(:sshd_config_subsystem).new( - :name => "mysub", - :command => "/bin/bash", - :target => target, - :provider => "augeas" - )) - - aug_open(target, "Sshd.lns") do |aug| - aug.get("Subsystem/mysub").should == "/bin/bash" - end - end - end - - describe "when deleting settings" do - it "should delete a setting" do - expr = "Subsystem/sftp" - aug_open(target, "Sshd.lns") do |aug| - aug.match(expr).should_not == [] - end - - apply!(Puppet::Type.type(:sshd_config_subsystem).new( - :name => "sftp", - :ensure => "absent", - :target => target, - :provider => "augeas" - )) - - aug_open(target, "Sshd.lns") do |aug| - aug.match(expr).should == [] - end - end - end - - describe "when updating settings" do - it "should replace a setting" do - apply!(Puppet::Type.type(:sshd_config_subsystem).new( - :name => "sftp", - :command => "/bin/bash", - :target => target, - :provider => "augeas" - )) - - aug_open(target, "Sshd.lns") do |aug| - aug.get("Subsystem/sftp").should == "/bin/bash" - end - end - end - end - - context "with broken file" do - let(:tmptarget) { aug_fixture("broken") } - let(:target) { tmptarget.path } - - it "should fail to load" do - txn = apply(Puppet::Type.type(:sshd_config_subsystem).new( - :name => "sftp", - :command => "/bin/bash", - :target => target, - :provider => "augeas" - )) - - txn.any_failed?.should_not == nil - @logs.first.level.should == :err - @logs.first.message.include?(target).should == true - end - end -end diff --git a/spec/unit/puppet/provider/sysctl/augeas_spec.rb b/spec/unit/puppet/provider/sysctl/augeas_spec.rb deleted file mode 100755 index 79207ee..0000000 --- a/spec/unit/puppet/provider/sysctl/augeas_spec.rb +++ /dev/null @@ -1,405 +0,0 @@ -#!/usr/bin/env rspec - -require 'spec_helper' - -provider_class = Puppet::Type.type(:sysctl).provider(:augeas) - -describe provider_class do - before :each do - FileTest.stubs(:exist?).returns false - FileTest.stubs(:exist?).with('/etc/sysctl.conf').returns true - end - - before(:all) { @tmpdir = Dir.mktmpdir } - after(:all) { FileUtils.remove_entry_secure @tmpdir } - - context "with no existing file" do - let(:target) { File.join(@tmpdir, "new_file") } - - before :each do - provider_class.expects(:sysctl).with('-w', 'net.ipv4.ip_forward=1') - provider_class.expects(:sysctl).with('-n', 'net.ipv4.ip_forward').returns('1') - end - - it "should create simple new entry" do - apply!(Puppet::Type.type(:sysctl).new( - :name => "net.ipv4.ip_forward", - :value => "1", - :target => target, - :provider => "augeas" - )) - - augparse(target, "Sysctl.lns", ' - { "net.ipv4.ip_forward" = "1" } - ') - end - end - - context "with empty file" do - let(:tmptarget) { aug_fixture("empty") } - let(:target) { tmptarget.path } - - before :each do - provider_class.expects(:sysctl).with('-w', 'net.ipv4.ip_forward=1') - provider_class.expects(:sysctl).with('-n', 'net.ipv4.ip_forward').returns('1') - end - - it "should create simple new entry" do - apply!(Puppet::Type.type(:sysctl).new( - :name => "net.ipv4.ip_forward", - :value => "1", - :target => target, - :provider => "augeas" - )) - - augparse(target, "Sysctl.lns", ' - { "net.ipv4.ip_forward" = "1" } - ') - end - - it "should create an entry using the val parameter instead of value" do - apply!(Puppet::Type.type(:sysctl).new( - :name => "net.ipv4.ip_forward", - :val => "1", - :target => target, - :provider => "augeas" - )) - - augparse(target, "Sysctl.lns", ' - { "net.ipv4.ip_forward" = "1" } - ') - end - - it "should create new entry with comment" do - apply!(Puppet::Type.type(:sysctl).new( - :name => "net.ipv4.ip_forward", - :value => "1", - :comment => "test", - :target => target, - :provider => "augeas" - )) - - augparse(target, "Sysctl.lns", ' - { "#comment" = "net.ipv4.ip_forward: test" } - { "net.ipv4.ip_forward" = "1" } - ') - end - end - - context "with full file" do - let(:tmptarget) { aug_fixture("full") } - let(:target) { tmptarget.path } - - it "should list instances" do - provider_class.stubs(:target).returns(target) - inst = provider_class.instances.map { |p| - { - :name => p.get(:name), - :ensure => p.get(:ensure), - :value => p.get(:value), - :comment => p.get(:comment), - } - } - - inst.size.should == 7 - inst[0].should == {:name=>"net.ipv4.ip_forward", :ensure=>:present, :value=>"0", :comment=>:absent} - inst[1].should == {:name=>"net.ipv4.conf.default.rp_filter", :ensure=>:present, :value=>"1", :comment=>:absent} - inst[2].should == {:name=>"net.ipv4.conf.default.accept_source_route", :ensure=>:present, :value=>"0", :comment=>"Do not accept source routing"} - inst[3].should == {:name=>"kernel.sysrq", :ensure=>:present, :value=>"0", :comment=>"controls the System Request debugging functionality of the kernel"} - end - - it "should create new entry next to commented out entry" do - provider_class.expects(:sysctl).with('-n', 'net.bridge.bridge-nf-call-iptables').returns('1') - provider_class.expects(:sysctl).with('-w', 'net.bridge.bridge-nf-call-iptables=1') - apply!(Puppet::Type.type(:sysctl).new( - :name => "net.bridge.bridge-nf-call-iptables", - :value => "1", - :target => target, - :provider => "augeas" - )) - - augparse_filter(target, "Sysctl.lns", '*[preceding-sibling::#comment[.="Disable netfilter on bridges."]]', ' - { "net.bridge.bridge-nf-call-ip6tables" = "0" } - { "#comment" = "net.bridge.bridge-nf-call-iptables = 0" } - { "net.bridge.bridge-nf-call-iptables" = "1" } - { "net.bridge.bridge-nf-call-arptables" = "0" } - ') - end - - it "should equate multi-part values with tabs in" do - provider_class.expects(:sysctl).with('-n', 'kernel.sem').returns("150\t12000\t12\t1000") - provider_class.expects(:sysctl).with('-w', 'kernel.sem=150 12000 12 1000') - - apply!(Puppet::Type.type(:sysctl).new( - :name => "kernel.sem", - :value => "150 12000 12 1000", - :apply => true, - :target => target, - :provider => "augeas" - )) - - augparse_filter(target, "Sysctl.lns", "kernel.sem", ' - { "kernel.sem" = "150 12000 12 1000" } - ') - end - - it "should delete entries" do - apply!(Puppet::Type.type(:sysctl).new( - :name => "kernel.sysrq", - :ensure => "absent", - :target => target, - :provider => "augeas" - )) - - aug_open(target, "Sysctl.lns") do |aug| - aug.match("kernel.sysrq").should == [] - aug.match("#comment[. =~ regexp('kernel.sysrq:.*')]").should == [] - end - end - - context 'when system and config values are set to different values' do - it "should update value with augeas and sysctl" do - provider_class.expects(:sysctl).with('-n', 'net.ipv4.ip_forward').twice.returns('3').then.returns('1') - provider_class.expects(:sysctl).with('-w', 'net.ipv4.ip_forward=1') - - apply!(Puppet::Type.type(:sysctl).new( - :name => "net.ipv4.ip_forward", - :value => "1", - :apply => true, - :target => target, - :provider => "augeas" - )) - - augparse_filter(target, "Sysctl.lns", "net.ipv4.ip_forward", ' - { "net.ipv4.ip_forward" = "1" } - ') - - @logs.first.should_not be_nil - @logs.first.message.should == "changed configuration value from '0' to '1' and live value from '3' to '1'" - end - - it "should update value with augeas only" do - provider_class.expects(:sysctl).with('-n', 'net.ipv4.ip_forward').never - provider_class.expects(:sysctl).with('-w', 'net.ipv4.ip_forward=1').never - - apply!(Puppet::Type.type(:sysctl).new( - :name => "net.ipv4.ip_forward", - :value => "1", - :apply => false, - :target => target, - :provider => "augeas" - )) - - augparse_filter(target, "Sysctl.lns", "net.ipv4.ip_forward", ' - { "net.ipv4.ip_forward" = "1" } - ') - - @logs.first.should_not be_nil - @logs.first.message.should == "changed configuration value from '0' to '1'" - end - end - - context 'when system and config values are set to the same value' do - it "should update value with augeas and sysctl" do - provider_class.expects(:sysctl).with('-n', 'net.ipv4.ip_forward').twice.returns('0').then.returns('1') - provider_class.expects(:sysctl).with('-w', 'net.ipv4.ip_forward=1') - - apply!(Puppet::Type.type(:sysctl).new( - :name => "net.ipv4.ip_forward", - :value => "1", - :apply => true, - :target => target, - :provider => "augeas" - )) - - augparse_filter(target, "Sysctl.lns", "net.ipv4.ip_forward", ' - { "net.ipv4.ip_forward" = "1" } - ') - - @logs.first.should_not be_nil - @logs.first.message.should == "changed configuration value from '0' to '1' and live value from '0' to '1'" - end - - it "should update value with augeas only" do - provider_class.expects(:sysctl).with('-n', 'net.ipv4.ip_forward').never - provider_class.expects(:sysctl).with('-w', 'net.ipv4.ip_forward=1').never - - apply!(Puppet::Type.type(:sysctl).new( - :name => "net.ipv4.ip_forward", - :value => "1", - :apply => false, - :target => target, - :provider => "augeas" - )) - - augparse_filter(target, "Sysctl.lns", "net.ipv4.ip_forward", ' - { "net.ipv4.ip_forward" = "1" } - ') - - @logs.first.should_not be_nil - @logs.first.message.should == "changed configuration value from '0' to '1'" - end - end - - context 'when only system value is set to target value' do - it "should update value with augeas only" do - provider_class.expects(:sysctl).with('-n', 'net.ipv4.ip_forward').twice.returns('1') - # Values not in sync, system update forced anyway - provider_class.expects(:sysctl).with('-w', 'net.ipv4.ip_forward=1').once.returns('1') - - apply!(Puppet::Type.type(:sysctl).new( - :name => "net.ipv4.ip_forward", - :value => "1", - :apply => true, - :target => target, - :provider => "augeas" - )) - - augparse_filter(target, "Sysctl.lns", "net.ipv4.ip_forward", ' - { "net.ipv4.ip_forward" = "1" } - ') - - @logs.first.should_not be_nil - @logs.first.message.should == "changed configuration value from '0' to '1'" - end - - it "should update value with augeas only and never run sysctl" do - provider_class.expects(:sysctl).with('-n', 'net.ipv4.ip_forward').never - provider_class.expects(:sysctl).with('-w', 'net.ipv4.ip_forward=1').never - - apply!(Puppet::Type.type(:sysctl).new( - :name => "net.ipv4.ip_forward", - :value => "1", - :apply => false, - :target => target, - :provider => "augeas" - )) - - augparse_filter(target, "Sysctl.lns", "net.ipv4.ip_forward", ' - { "net.ipv4.ip_forward" = "1" } - ') - - @logs.first.should_not be_nil - @logs.first.message.should == "changed configuration value from '0' to '1'" - end - end - - context 'when only config value is set to target value' do - it "should update value with sysctl only" do - provider_class.expects(:sysctl).with('-n', 'net.ipv4.ip_forward').twice.returns('1').then.returns('0') - # Values not in sync, system update forced anyway - provider_class.expects(:sysctl).with('-w', 'net.ipv4.ip_forward=0').once.returns('0') - - apply!(Puppet::Type.type(:sysctl).new( - :name => "net.ipv4.ip_forward", - :value => "0", - :apply => true, - :target => target, - :provider => "augeas" - )) - - augparse_filter(target, "Sysctl.lns", "net.ipv4.ip_forward", ' - { "net.ipv4.ip_forward" = "0" } - ') - - @logs.first.should_not be_nil - @logs.first.message.should == "changed live value from '1' to '0'" - end - - it "should not update value with sysctl" do - provider_class.expects(:sysctl).with('-n', 'net.ipv4.ip_forward').never - provider_class.expects(:sysctl).with('-w', 'net.ipv4.ip_forward=0').never - - apply!(Puppet::Type.type(:sysctl).new( - :name => "net.ipv4.ip_forward", - :value => "0", - :apply => false, - :target => target, - :provider => "augeas" - )) - - augparse_filter(target, "Sysctl.lns", "net.ipv4.ip_forward", ' - { "net.ipv4.ip_forward" = "0" } - ') - - @logs.first.should be_nil - end - end - - context "when updating comment" do - it "should change comment" do - apply!(Puppet::Type.type(:sysctl).new( - :name => "kernel.sysrq", - :comment => "enables the SysRq feature", - :target => target, - :provider => "augeas" - )) - - aug_open(target, "Sysctl.lns") do |aug| - aug.match("#comment[. = 'SysRq setting']").should_not == [] - aug.match("#comment[. = 'kernel.sysrq: enables the SysRq feature']").should_not == [] - end - end - - it "should remove comment" do - apply!(Puppet::Type.type(:sysctl).new( - :name => "kernel.sysrq", - :comment => "", - :target => target, - :provider => "augeas" - )) - - aug_open(target, "Sysctl.lns") do |aug| - aug.match("#comment[. =~ regexp('kernel.sysrq:.*')]").should == [] - aug.match("#comment[. = 'SysRq setting']").should_not == [] - end - end - end - end - - context "with small file" do - let(:tmptarget) { aug_fixture("small") } - let(:target) { tmptarget.path } - - describe "when updating comment" do - it "should add comment" do - apply!(Puppet::Type.type(:sysctl).new( - :name => "net.ipv4.ip_forward", - :comment => "test comment", - :target => target, - :provider => "augeas" - )) - - augparse(target, "Sysctl.lns", ' - { "#comment" = "Kernel sysctl configuration file" } - { } - { "#comment" = "For binary values, 0 is disabled, 1 is enabled. See sysctl(8) and" } - { "#comment" = "sysctl.conf(5) for more details." } - { } - { "#comment" = "Controls IP packet forwarding" } - { "#comment" = "net.ipv4.ip_forward: test comment" } - { "net.ipv4.ip_forward" = "0" } - { } - ') - end - end - end - - context "with broken file" do - let(:tmptarget) { aug_fixture("broken") } - let(:target) { tmptarget.path } - - it "should fail to load" do - txn = apply(Puppet::Type.type(:sysctl).new( - :name => "net.ipv4.ip_forward", - :value => "1", - :target => target, - :provider => "augeas" - )) - - txn.any_failed?.should_not == nil - @logs.first.level.should == :err - @logs.first.message.include?(target).should == true - end - end -end diff --git a/spec/unit/puppet/provider/syslog/augeas_spec.rb b/spec/unit/puppet/provider/syslog/augeas_spec.rb deleted file mode 100644 index d351c00..0000000 --- a/spec/unit/puppet/provider/syslog/augeas_spec.rb +++ /dev/null @@ -1,164 +0,0 @@ -#!/usr/bin/env rspec - -require 'spec_helper' - -FileTest.stubs(:exist?).returns false -FileTest.stubs(:exist?).with('/etc/syslog.conf').returns true -provider_class = Puppet::Type.type(:syslog).provider(:augeas) - -describe provider_class do - before :each do - FileTest.stubs(:exist?).returns false - FileTest.stubs(:exist?).with('/etc/syslog.conf').returns true - end - - context "with empty file" do - let(:tmptarget) { aug_fixture("empty") } - let(:target) { tmptarget.path } - - it "should create simple new entry" do - apply!(Puppet::Type.type(:syslog).new( - :name => "my test", - :facility => "local2", - :level => "*", - :action_type => "file", - :action => "/var/log/test.log", - :target => target, - :provider => "augeas", - :ensure => "present" - )) - - aug_open(target, "Syslog.lns") do |aug| - aug.match("entry").size.should == 1 - aug.get("entry/action/file").should == "/var/log/test.log" - aug.match("entry/action/no_sync").size.should == 0 - end - end - end - - context "with full file" do - let(:tmptarget) { aug_fixture("full") } - let(:target) { tmptarget.path } - - it "should list instances" do - provider_class.stubs(:target).returns(target) - inst = provider_class.instances.map { |p| - { - :name => p.get(:name), - :ensure => p.get(:ensure), - :facility => p.get(:facility), - :level => p.get(:level), - :no_sync => p.get(:no_sync), - :action_type => p.get(:action_type), - :action => p.get(:action), - } - } - - inst.size.should == 10 - inst[0].should == {:name=>"*.info /var/log/messages", :ensure=>:present, :facility=>"*", :level=>"info", :no_sync=>:false, :action_type=>"file", :action=>"/var/log/messages"} - inst[1].should == {:name=>"mail.none /var/log/messages", :ensure=>:present, :facility=>"mail", :level=>"none", :no_sync=>:false, :action_type=>"file", :action=>"/var/log/messages"} - inst[5].should == {:name=>"mail.* -/var/log/maillog", :ensure=>:present, :facility=>"mail", :level=>"*", :no_sync=>:true, :action_type=>"file", :action=>"/var/log/maillog"} - inst[8].should == {:name=>"uucp.crit /var/log/spooler", :ensure=>:present, :facility=>"uucp", :level=>"crit", :no_sync=>:false, :action_type=>"file", :action=>"/var/log/spooler"} - inst[9].should == {:name=>"news.crit /var/log/spooler", :ensure=>:present, :facility=>"news", :level=>"crit", :no_sync=>:false, :action_type=>"file", :action=>"/var/log/spooler"} - end - - describe "when creating settings" do - it "should create a simple new entry" do - apply!(Puppet::Type.type(:syslog).new( - :name => "my test", - :facility => "local2", - :level => "info", - :action_type => "file", - :action => "/var/log/test.log", - :target => target, - :provider => "augeas", - :ensure => "present" - )) - - aug_open(target, "Syslog.lns") do |aug| - aug.get("entry[selector/facility='local2']/action/file").should == "/var/log/test.log" - aug.match("entry[selector/facility='local2']/action/no_sync").size.should == 0 - end - end - end - - describe "when modifying settings" do - it "should add a no_sync flag" do - apply!(Puppet::Type.type(:syslog).new( - :name => "cron.*", - :facility => "cron", - :level => "*", - :action_type => "file", - :action => "/var/log/cron", - :target => target, - :no_sync => :true, - :provider => "augeas", - :ensure => "present" - )) - - aug_open(target, "Syslog.lns") do |aug| - aug.match("entry[selector/facility='cron']/action/no_sync").size.should == 1 - end - end - - it "should remove the no_sync flag" do - apply!(Puppet::Type.type(:syslog).new( - :name => "mail.*", - :facility => "mail", - :level => "*", - :action_type => "file", - :action => "/var/log/maillog", - :target => target, - :no_sync => :false, - :provider => "augeas", - :ensure => "present" - )) - - aug_open(target, "Syslog.lns") do |aug| - aug.match("entry[selector/facility='mail']/action/no_sync").size.should == 0 - end - end - end - - describe "when removing settings" do - it "should remove the entry" do - apply!(Puppet::Type.type(:syslog).new( - :name => "mail.*", - :facility => "mail", - :level => "*", - :action_type => "file", - :action => "/var/log/maillog", - :target => target, - :provider => "augeas", - :ensure => "absent" - )) - - aug_open(target, "Syslog.lns") do |aug| - aug.match("entry[selector/facility='mail' and level='*']").size.should == 0 - end - end - end - end - - context "with broken file" do - let(:tmptarget) { aug_fixture("broken") } - let(:target) { tmptarget.path } - - it "should fail to load" do - txn = apply(Puppet::Type.type(:syslog).new( - :name => "mail.*", - :facility => "mail", - :level => "*", - :action_type => "file", - :action => "/var/log/maillog", - :target => target, - :provider => "augeas", - :ensure => "present" - )) - - txn.any_failed?.should_not == nil - @logs.first.level.should == :err - @logs.first.message.include?(target).should == true - end - end -end diff --git a/spec/unit/puppet/provider/syslog/rsyslog_spec.rb b/spec/unit/puppet/provider/syslog/rsyslog_spec.rb deleted file mode 100644 index 4f62533..0000000 --- a/spec/unit/puppet/provider/syslog/rsyslog_spec.rb +++ /dev/null @@ -1,168 +0,0 @@ -#!/usr/bin/env rspec - -require 'spec_helper' - -FileTest.stubs(:exist?).returns false -FileTest.stubs(:exist?).with('/etc/rsyslog.conf').returns true -provider_class = Puppet::Type.type(:syslog).provider(:rsyslog) -def valid_lens? - # This lens breaks on Augeas 0.10.0 - Puppet::Util::Package.versioncmp(Puppet::Type.type(:mailalias).provider(:augeas).aug_version, '0.10.0') > 0 -end - -describe provider_class, :if => valid_lens? do - before :each do - FileTest.stubs(:exist?).returns false - FileTest.stubs(:exist?).with('/etc/rsyslog.conf').returns true - end - - context "with empty file" do - let(:tmptarget) { aug_fixture("empty") } - let(:target) { tmptarget.path } - - it "should create simple new entry" do - apply!(Puppet::Type.type(:syslog).new( - :name => "my test", - :facility => "local2", - :level => "*", - :action_type => "file", - :action => "/var/log/test.log", - :target => target, - :provider => "rsyslog", - :ensure => "present" - )) - - aug_open(target, "Rsyslog.lns") do |aug| - aug.match("entry").size.should == 1 - aug.get("entry/action/file").should == "/var/log/test.log" - aug.match("entry/action/no_sync").size.should == 0 - end - end - end - - context "with full file" do - let(:tmptarget) { aug_fixture("full") } - let(:target) { tmptarget.path } - - it "should list instances" do - provider_class.stubs(:target).returns(target) - inst = provider_class.instances.map { |p| - { - :name => p.get(:name), - :ensure => p.get(:ensure), - :facility => p.get(:facility), - :level => p.get(:level), - :no_sync => p.get(:no_sync), - :action_type => p.get(:action_type), - :action => p.get(:action), - } - } - - inst.size.should == 10 - inst[0].should == {:name=>"*.info /var/log/messages", :ensure=>:present, :facility=>"*", :level=>"info", :no_sync=>:false, :action_type=>"file", :action=>"/var/log/messages"} - inst[1].should == {:name=>"mail.none /var/log/messages", :ensure=>:present, :facility=>"mail", :level=>"none", :no_sync=>:false, :action_type=>"file", :action=>"/var/log/messages"} - inst[5].should == {:name=>"mail.* -/var/log/maillog", :ensure=>:present, :facility=>"mail", :level=>"*", :no_sync=>:true, :action_type=>"file", :action=>"/var/log/maillog"} - inst[8].should == {:name=>"news.crit /var/log/spooler", :ensure=>:present, :facility=>"news", :level=>"crit", :no_sync=>:false, :action_type=>"file", :action=>"/var/log/spooler"} - inst[9].should == {:name=>"local7.* /var/log/boot.log", :ensure=>:present, :facility=>"local7", :level=>"*", :no_sync=>:false, :action_type=>"file", :action=>"/var/log/boot.log"} - end - - describe "when creating settings" do - it "should create a simple new entry" do - apply!(Puppet::Type.type(:syslog).new( - :name => "my test", - :facility => "local2", - :level => "info", - :action_type => "file", - :action => "/var/log/test.log", - :target => target, - :provider => "rsyslog", - :ensure => "present" - )) - - aug_open(target, "Rsyslog.lns") do |aug| - aug.get("entry[selector/facility='local2']/action/file").should == "/var/log/test.log" - aug.match("entry[selector/facility='local2']/action/no_sync").size.should == 0 - end - end - end - - describe "when modifying settings" do - it "should add a no_sync flag" do - apply!(Puppet::Type.type(:syslog).new( - :name => "cron.*", - :facility => "cron", - :level => "*", - :action_type => "file", - :action => "/var/log/cron", - :target => target, - :no_sync => :true, - :provider => "rsyslog", - :ensure => "present" - )) - - aug_open(target, "Rsyslog.lns") do |aug| - aug.match("entry[selector/facility='cron']/action/no_sync").size.should == 1 - end - end - - it "should remove the no_sync flag" do - apply!(Puppet::Type.type(:syslog).new( - :name => "mail.*", - :facility => "mail", - :level => "*", - :action_type => "file", - :action => "/var/log/maillog", - :target => target, - :no_sync => :false, - :provider => "rsyslog", - :ensure => "present" - )) - - aug_open(target, "Rsyslog.lns") do |aug| - aug.match("entry[selector/facility='mail']/action/no_sync").size.should == 0 - end - end - end - - describe "when removing settings" do - it "should remove the entry" do - apply!(Puppet::Type.type(:syslog).new( - :name => "mail.*", - :facility => "mail", - :level => "*", - :action_type => "file", - :action => "/var/log/maillog", - :target => target, - :provider => "rsyslog", - :ensure => "absent" - )) - - aug_open(target, "Rsyslog.lns") do |aug| - aug.match("entry[selector/facility='mail' and level='*']").size.should == 0 - end - end - end - end - - context "with broken file" do - let(:tmptarget) { aug_fixture("broken") } - let(:target) { tmptarget.path } - - it "should fail to load" do - txn = apply(Puppet::Type.type(:syslog).new( - :name => "mail.*", - :facility => "mail", - :level => "*", - :action_type => "file", - :action => "/var/log/maillog", - :target => target, - :provider => "rsyslog", - :ensure => "present" - )) - - txn.any_failed?.should_not == nil - @logs.first.level.should == :err - @logs.first.message.include?(target).should == true - end - end -end diff --git a/spec/unit/puppet/type/shellvar_type_spec.rb b/spec/unit/puppet/type/shellvar_type_spec.rb deleted file mode 100755 index a9c9118..0000000 --- a/spec/unit/puppet/type/shellvar_type_spec.rb +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env rspec - -require 'spec_helper' - -describe Puppet::Type.type(:shellvar) do - describe "when setting quoted" do - it "should have a default of auto" do - resource = Puppet::Type.type(:shellvar).new :variable => "foo" - resource[:quoted].should == :auto - end - - it "should convert true to auto" do - resource = Puppet::Type.type(:shellvar).new :variable => "foo", :quoted => :true - resource[:quoted].should == :auto - end - - it "should convert false to none" do - resource = Puppet::Type.type(:shellvar).new :variable => "foo", :quoted => :false - resource[:quoted].should == :none - end - end -end From 12b7a59102cc15da84cf795d931e76d9653b58e0 Mon Sep 17 00:00:00 2001 From: Dominic Cleal Date: Mon, 5 May 2014 18:04:35 +0100 Subject: [PATCH 02/29] Change project metadata to augeasproviders_core --- Modulefile | 6 +-- README.md | 130 ++++++----------------------------------------------- 2 files changed, 16 insertions(+), 120 deletions(-) diff --git a/Modulefile b/Modulefile index ee61700..3527e1f 100644 --- a/Modulefile +++ b/Modulefile @@ -1,11 +1,11 @@ -name 'domcleal-augeasproviders' +name 'herculesteam-augeasproviders_core' version '1.1.0' -source 'git://github.com/hercules-team/augeasproviders' +source 'git://github.com/hercules-team/augeasproviders_core' author 'Dominic Cleal, Raphael Pinson' license 'Apache 2.0' summary 'Alternative Augeas-based providers for Puppet' description 'This module provides alternative providers for core Puppet types using the Augeas configuration API library.' -project_page 'http://github.com/hercules-team/augeasproviders' +project_page 'http://augeasproviders.com' dependency 'puppetlabs/stdlib', '>=3.2.0 <5.0.0' ## Add dependencies, if any: diff --git a/README.md b/README.md index 4c55962..13c53df 100644 --- a/README.md +++ b/README.md @@ -1,59 +1,22 @@ -# augeasproviders: alternative Augeas-based providers for Puppet +# augeasproviders\_core: library for building alternative Augeas-based providers for Puppet -This module provides alternative providers for core Puppet types such as -`host` and `mailalias` using the Augeas configuration library. It also adds -some of its own types for new functionality. +This module provides a library for module authors to create new types and +providers around config files, using the Augeas configuration library to read +and modify them. The advantage of using Augeas over the default Puppet `parsedfile` implementations is that Augeas will go to great lengths to preserve file formatting and comments, while also failing safely when needed. -These providers will hide *all* of the Augeas commands etc., you don't need to -know anything about Augeas to make use of it. +If you're a user, you want to see the main augeasproviders project at +[augeasproviders.com](http://augeasproviders.com). -If you want to make changes to config files in your own way, you should use -the `augeas` type directly. For more information about Augeas, see the -[web site](http://augeas.net) or the -[Puppet/Augeas](http://docs.puppetlabs.com/guides/augeas.html) -documentation. - -## Types and providers - -The following builtin types have an Augeas-based provider implemented: - -* `host` -* `mailalias` - -The following other types have a provider implemented: - -* `mounttab` from [puppetlabs-mount_providers](http://forge.puppetlabs.com/puppetlabs/mount_providers) - -The module adds the following new types: - -* `apache_directive` for updating generic Apache HTTP Server configs -* `apache_setenv` for updating SetEnv entries in Apache HTTP Server configs -* `kernel_parameter` for adding kernel parameters to GRUB Legacy or GRUB 2 configs -* `nrpe_command` for setting command entries in Nagios NRPE's `nrpe.cfg` -* `pam` for files inside /etc/pam.d/ -* `pg_hba` for PostgreSQL's `pg_hba.conf` entries -* `puppet_auth` for authentication rules in Puppet's `auth.conf` -* `shellvar` for shell variables in `/etc/sysconfig` or `/etc/default` etc. -* `sshd_config` for setting configuration entries in OpenSSH's `sshd_config` -* `sshd_config_subsystem` for setting subsystem entries in OpenSSH's `sshd_config` -* `sysctl` for entries inside Linux's sysctl.conf -* `syslog` for entries inside syslog.conf - -Lots of examples are provided in the accompanying documentation (see -`docs/examples.html`) and are also published [on the web site](http://augeasproviders.com/documentation/examples.html). -If this is a git checkout, you will need to run `make` in docs/ to generate the -HTML pages. +## Requirements -Type documentation can be generated with `puppet doc -r type` or viewed on the -[Puppet Forge page](http://forge.puppetlabs.com/domcleal/augeasproviders). +Ensure both Augeas and ruby-augeas 0.3.0+ bindings are installed and working as +normal. -For builtin types and mounttab, the default provider will automatically become -the `augeas` provider once the module is installed. This can be changed back -to `parsed` where necessary. +See [Puppet/Augeas pre-requisites](http://docs.puppetlabs.com/guides/augeas.html#pre-requisites). ## Classes @@ -95,77 +58,10 @@ A Hash that contains the default values used to create each resource. See *mani All types have a augeasproviders\_`TYPE`\_hash variable, where `TYPE` is the resource type. These variables accept a Hash to define that type's resources. -## Requirements - -Ensure both Augeas and ruby-augeas 0.3.0+ bindings are installed and working as -normal. - -See [Puppet/Augeas pre-requisites](http://docs.puppetlabs.com/guides/augeas.html#pre-requisites). - -## Installing - -On Puppet 2.7.14+, the module can be installed easily ([documentation](http://docs.puppetlabs.com/puppet/2.7/reference/modules_installing.html)): - - puppet module install domcleal/augeasproviders - -You may see an error similar to this on Puppet 2.x ([#13858](http://projects.puppetlabs.com/issues/13858)): - - Error 400 on SERVER: Puppet::Parser::AST::Resource failed with error ArgumentError: Invalid resource type `kernel_parameter` at ... - -Ensure the module is present in your puppetmaster's own environment (it doesn't -have to use it) and that the master has pluginsync enabled. Run the agent on -the puppetmaster to cause the custom types to be synced to its local libdir -(`puppet master --configprint libdir`) and then restart the puppetmaster so it -loads them. - -## Planned - -The following builtin types have Augeas-based providers planned: - -* `ssh_authorized_key` -* `port`, once [#5660](http://projects.puppetlabs.com/issues/5660) is done -* `yumrepo`, once [#8758](http://projects.puppetlabs.com/issues/8758) is done - -Other ideas for new types are: - -* `/etc/system` types - -## Compatibility - -### Puppet versions - -Puppet Versions | 2.7 -> 3.4 | >= 3.4 | -:---------------|:----------:|:-------:| -compatibility | **yes** | **yes** | -shared handler | no | **yes** | - -### Augeas versions - -Augeas Versions | 0.10.0 | 1.0.0 | 1.1.0 | 1.2.0 | -:-------------------------|:-------:|:-------:|:-------:|:-------:| -**FEATURES** | -case-insensitive keys | no | **yes** | **yes** | **yes** | -**PROVIDERS** | -apache\_directive | **yes** | **yes** | **yes** | **yes** | -apache\_setenv | **yes** | **yes** | **yes** | **yes** | -host | **yes** | **yes** | **yes** | **yes** | -kernel\_parameter (grub) | **yes** | **yes** | **yes** | **yes** | -kernel\_parameter (grub2) | **yes** | **yes** | **yes** | **yes** | -mailalias | **yes** | **yes** | **yes** | **yes** | -mounttab (fstab) | **yes** | **yes** | **yes** | **yes** | -mounttab (vfstab) | no | **yes** | **yes** | **yes** | -nrpe\_command | **yes** | **yes** | **yes** | **yes** | -pg\_hba | no | **yes** | **yes** | **yes** | -puppet\_auth | no | **yes** | **yes** | **yes** | -shellvar | **yes** | **yes** | **yes** | **yes** | -sshd\_config | **yes** | **yes** | **yes** | **yes** | -sshd\_config\_subsystem | **yes** | **yes** | **yes** | **yes** | -sysctl | **yes** | **yes** | **yes** | **yes** | -syslog (augeas) | **yes** | **yes** | **yes** | **yes** | -syslog (rsyslog) | no | **yes** | **yes** | **yes** | - +## Development documentation +See docs/ (run `make`) or [augeasproviders.com](http://augeasproviders.com/documentation/). ## Issues -Please file any issues or suggestions [on GitHub](https://github.com/hercules-team/augeasproviders/issues). +Please file any issues or suggestions [on GitHub](https://github.com/hercules-team/augeasproviders_core/issues). From c032a33ea1c75a646f512f94e28e583bd230e9cd Mon Sep 17 00:00:00 2001 From: Dominic Cleal Date: Wed, 14 May 2014 22:15:59 +0100 Subject: [PATCH 03/29] Fix use of seq entries with Puppet 3.4 optimisation (GH issue #101) * Add a new next_seq method --- lib/puppet/provider/augeasprovider/default.rb | 21 +++++++++++++++++++ .../provider/augeasprovider/default_spec.rb | 18 ++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/lib/puppet/provider/augeasprovider/default.rb b/lib/puppet/provider/augeasprovider/default.rb index f57be21..95fceee 100644 --- a/lib/puppet/provider/augeasprovider/default.rb +++ b/lib/puppet/provider/augeasprovider/default.rb @@ -47,6 +47,17 @@ def self.supported?(feature) end end + # Returns a node label to use for creating a new entry in an Augeas sequence + # (seq), given the current list, e.g. '1' if it's the first. Supply + # aug.match('$target/*') or similar. + # + # @param [Array] existing paths, from Augeas#match + # @return [String] new node label + def self.next_seq(matches) + last = matches.map {|p| path_label(nil, p).to_i }.max || 0 + (last + 1).to_s + end + # Returns an Augeas handler. # # On Puppet >= 3.4, stores and returns a shared Augeas handler @@ -914,4 +925,14 @@ def destroy def flush augsave!(aug_handler, true) if supported?(:post_resource_eval) end + + # Returns a node label to use for creating a new entry in an Augeas sequence + # (seq), given the current list, e.g. '1' if it's the first. Supply + # aug.match('$target/*') or similar. + # + # @param [Array] existing paths, from Augeas#match + # @return [String] new node label + def next_seq(matches) + self.class.next_seq(matches) + end end diff --git a/spec/unit/puppet/provider/augeasprovider/default_spec.rb b/spec/unit/puppet/provider/augeasprovider/default_spec.rb index 99aadc2..28dec34 100755 --- a/spec/unit/puppet/provider/augeasprovider/default_spec.rb +++ b/spec/unit/puppet/provider/augeasprovider/default_spec.rb @@ -188,6 +188,24 @@ class Empty < provider_class subject.attr_aug_accessor(name, opts) end end + + describe "#next_seq" do + it "should return 1 with no paths" do + subject.new.next_seq([]).should == '1' + end + + it "should return 1 with only comments" do + subject.new.next_seq(['/files/etc/hosts/#comment[1]']).should == '1' + end + + it "should return 2 when 1 exists" do + subject.new.next_seq(['/files/etc/hosts/1']).should == '2' + end + + it "should return 42 when 1..41 exists" do + subject.new.next_seq((1..41).map {|n| "/files/etc/hosts/#{n}"}).should == '42' + end + end end context "working provider" do From 2c3f228bbfd2a18c83c63ec9553764a4c572f5e6 Mon Sep 17 00:00:00 2001 From: Dominic Cleal Date: Tue, 10 Jun 2014 10:54:49 -0400 Subject: [PATCH 04/29] Retry Travis build steps --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index c099d22..bf014e2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -65,6 +65,6 @@ matrix: - rvm: 2.0.0 env: PUPPET=3.4 RUBY_AUGEAS=0.3.0 AUGEAS=1.1.0 LENSES=HEAD install: - - ./.travis.sh + - "travis_retry ./.travis.sh" script: - AUGEAS_LENS_LIB=augeas/lenses bundle exec rake From 691ab78f72acfe5f14d894400f34505f779a45b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Pinson?= Date: Mon, 4 Aug 2014 11:47:48 +0200 Subject: [PATCH 05/29] Load shared contexts and shared examples --- spec/spec_helper.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index c2d138a..649e9b0 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -19,3 +19,6 @@ require 'augeas_spec' Puppet[:modulepath] = File.join(dir, 'fixtures', 'modules') + +# Load all shared contexts and shared examples +Dir["#{dir}/support/**/*.rb"].sort.each {|f| require f} From e52a4cc2c42c8c9e83a3160f147c871776addf81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Pinson?= Date: Mon, 4 Aug 2014 14:47:42 +0200 Subject: [PATCH 06/29] Filter warnings about directory environments in fixtures.rb --- spec/lib/augeas_spec/fixtures.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/lib/augeas_spec/fixtures.rb b/spec/lib/augeas_spec/fixtures.rb index 7ab63e1..551ae5b 100644 --- a/spec/lib/augeas_spec/fixtures.rb +++ b/spec/lib/augeas_spec/fixtures.rb @@ -28,7 +28,7 @@ def apply!(*resources) # Check for warning+ log messages loglevels = Puppet::Util::Log.levels[3, 999] firstlogs = @logs.dup - @logs.select { |log| loglevels.include? log.level }.should == [] + @logs.select { |log| loglevels.include? log.level and log.message !~ /'modulepath' as a setting/ }.should == [] # Check for transaction success after, as it's less informative txn.any_failed?.should_not be_true From 729d96cbfbac2df64acb1b888f5159b2a62465bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Pinson?= Date: Tue, 5 Aug 2014 10:26:46 +0200 Subject: [PATCH 07/29] Add augeasproviders_shellvar to .fixtures.yml --- .fixtures.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.fixtures.yml b/.fixtures.yml index 7b78229..fbaac4c 100644 --- a/.fixtures.yml +++ b/.fixtures.yml @@ -3,5 +3,7 @@ fixtures: stdlib: repo: git://github.com/puppetlabs/puppetlabs-stdlib.git ref: 4.1.0 + augeasproviders_shellvar: + repo: git@github.com:hercules-team/augeasproviders_shellvar.git symlinks: - "augeasprovider_core": "#{source_dir}" + "augeasproviders": "#{source_dir}" From d8cc77ce0374947222c73ca0d07f1e1bcc779488 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Pinson?= Date: Tue, 5 Aug 2014 10:40:54 +0200 Subject: [PATCH 08/29] Add ssh --- .fixtures.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.fixtures.yml b/.fixtures.yml index fbaac4c..de7ba54 100644 --- a/.fixtures.yml +++ b/.fixtures.yml @@ -4,6 +4,8 @@ fixtures: repo: git://github.com/puppetlabs/puppetlabs-stdlib.git ref: 4.1.0 augeasproviders_shellvar: - repo: git@github.com:hercules-team/augeasproviders_shellvar.git + repo: git://github.com/hercules-team/augeasproviders_shellvar.git + augeasproviders_ssh: + repo: git://github.com/hercules-team/augeasproviders_ssh.git symlinks: "augeasproviders": "#{source_dir}" From 6d86d79af7d40874f5c4f348229e941791575f82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Pinson?= Date: Tue, 5 Aug 2014 11:01:45 +0200 Subject: [PATCH 09/29] Add apache --- .fixtures.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.fixtures.yml b/.fixtures.yml index de7ba54..4e5684a 100644 --- a/.fixtures.yml +++ b/.fixtures.yml @@ -3,6 +3,8 @@ fixtures: stdlib: repo: git://github.com/puppetlabs/puppetlabs-stdlib.git ref: 4.1.0 + augeasproviders_apache: + repo: git://github.com/hercules-team/augeasproviders_apache.git augeasproviders_shellvar: repo: git://github.com/hercules-team/augeasproviders_shellvar.git augeasproviders_ssh: From ed411d293a4fe05f9e4f6d411079b6201f683558 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Pinson?= Date: Tue, 5 Aug 2014 15:36:09 +0200 Subject: [PATCH 10/29] Add sysctl and syslog --- .fixtures.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.fixtures.yml b/.fixtures.yml index 4e5684a..cefcd19 100644 --- a/.fixtures.yml +++ b/.fixtures.yml @@ -9,5 +9,9 @@ fixtures: repo: git://github.com/hercules-team/augeasproviders_shellvar.git augeasproviders_ssh: repo: git://github.com/hercules-team/augeasproviders_ssh.git + augeasproviders_sysctl: + repo: git://github.com/hercules-team/augeasproviders_sysctl.git + augeasproviders_syslog: + repo: git://github.com/hercules-team/augeasproviders_syslog.git symlinks: "augeasproviders": "#{source_dir}" From 8d39b9423a7d4f8ad4818a0147975357e176d765 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Pinson?= Date: Wed, 6 Aug 2014 08:34:17 +0200 Subject: [PATCH 11/29] Add grub --- .fixtures.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.fixtures.yml b/.fixtures.yml index cefcd19..d3af12b 100644 --- a/.fixtures.yml +++ b/.fixtures.yml @@ -5,6 +5,8 @@ fixtures: ref: 4.1.0 augeasproviders_apache: repo: git://github.com/hercules-team/augeasproviders_apache.git + augeasproviders_grub: + repo: git://github.com/hercules-team/augeasproviders_grub.git augeasproviders_shellvar: repo: git://github.com/hercules-team/augeasproviders_shellvar.git augeasproviders_ssh: From 7a728fb8a7dbe4de2cff8f20ab110d67258d2b69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Pinson?= Date: Wed, 6 Aug 2014 08:49:39 +0200 Subject: [PATCH 12/29] Add nagios --- .fixtures.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.fixtures.yml b/.fixtures.yml index d3af12b..794d103 100644 --- a/.fixtures.yml +++ b/.fixtures.yml @@ -7,6 +7,8 @@ fixtures: repo: git://github.com/hercules-team/augeasproviders_apache.git augeasproviders_grub: repo: git://github.com/hercules-team/augeasproviders_grub.git + augeasproviders_nagios: + repo: git://github.com/hercules-team/augeasproviders_nagios.git augeasproviders_shellvar: repo: git://github.com/hercules-team/augeasproviders_shellvar.git augeasproviders_ssh: From 5c3f854f6824aa3f430f9dcf21a65126d9c8cb35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Pinson?= Date: Wed, 6 Aug 2014 09:08:46 +0200 Subject: [PATCH 13/29] Add postgresql --- .fixtures.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.fixtures.yml b/.fixtures.yml index 794d103..5c9c45a 100644 --- a/.fixtures.yml +++ b/.fixtures.yml @@ -9,6 +9,8 @@ fixtures: repo: git://github.com/hercules-team/augeasproviders_grub.git augeasproviders_nagios: repo: git://github.com/hercules-team/augeasproviders_nagios.git + augeasproviders_postgresql: + repo: git://github.com/hercules-team/augeasproviders_postgresql.git augeasproviders_shellvar: repo: git://github.com/hercules-team/augeasproviders_shellvar.git augeasproviders_ssh: From 2ccb6f1ff50d41c3e707e16ea5ae541560bf8e67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Pinson?= Date: Wed, 6 Aug 2014 09:42:50 +0200 Subject: [PATCH 14/29] Add pam --- .fixtures.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.fixtures.yml b/.fixtures.yml index 5c9c45a..881fab8 100644 --- a/.fixtures.yml +++ b/.fixtures.yml @@ -9,6 +9,8 @@ fixtures: repo: git://github.com/hercules-team/augeasproviders_grub.git augeasproviders_nagios: repo: git://github.com/hercules-team/augeasproviders_nagios.git + augeasproviders_pam: + repo: git://github.com/hercules-team/augeasproviders_pam.git augeasproviders_postgresql: repo: git://github.com/hercules-team/augeasproviders_postgresql.git augeasproviders_shellvar: From 9c607a50d6bbec9ffad310eaa86c5a3c38c77f18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Pinson?= Date: Wed, 6 Aug 2014 09:59:17 +0200 Subject: [PATCH 15/29] Add Coveralls support --- .coveralls.yml | 1 + Gemfile | 1 + spec/spec_helper.rb | 3 +++ 3 files changed, 5 insertions(+) create mode 100644 .coveralls.yml diff --git a/.coveralls.yml b/.coveralls.yml new file mode 100644 index 0000000..9160059 --- /dev/null +++ b/.coveralls.yml @@ -0,0 +1 @@ +service_name: travis-ci diff --git a/Gemfile b/Gemfile index c3b3c05..f77b35d 100644 --- a/Gemfile +++ b/Gemfile @@ -32,4 +32,5 @@ group :development do gem 'beaker', :require => false, :git => 'https://github.com/puppetlabs/beaker', :ref => 'dbac20fe9' gem 'beaker-rspec', :require => false gem 'vagrant-wrapper', :require => false + gem 'coveralls' end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 649e9b0..fbbe4e3 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -22,3 +22,6 @@ # Load all shared contexts and shared examples Dir["#{dir}/support/**/*.rb"].sort.each {|f| require f} + +require 'coveralls' +Coveralls.wear! From 07af328bec9d85c19f1a544f4613fb5e1531130a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Pinson?= Date: Wed, 6 Aug 2014 10:02:21 +0200 Subject: [PATCH 16/29] Use Coveralls formatter for SimpleCov --- spec/spec_helper.rb | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index fbbe4e3..0686f36 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -5,6 +5,8 @@ require 'rubygems' require 'simplecov' +require 'coveralls' +SimpleCov.formatter = Coveralls::SimpleCov::Formatter SimpleCov.start do add_filter "/spec/fixtures/modules/mount_providers/" add_filter { |src_file| @@ -22,6 +24,3 @@ # Load all shared contexts and shared examples Dir["#{dir}/support/**/*.rb"].sort.each {|f| require f} - -require 'coveralls' -Coveralls.wear! From 81cdae91c05313d3c81328c4750272aac528ebba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Pinson?= Date: Wed, 6 Aug 2014 10:30:05 +0200 Subject: [PATCH 17/29] Improve SimpleCov filters --- spec/spec_helper.rb | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 0686f36..d5f3bc3 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -8,13 +8,14 @@ require 'coveralls' SimpleCov.formatter = Coveralls::SimpleCov::Formatter SimpleCov.start do - add_filter "/spec/fixtures/modules/mount_providers/" - add_filter { |src_file| - # gets loaded via spec/fixtures/modules/ap/lib - src_file.filename.end_with?("/lib/augeasproviders/provider.rb") and not src_file.filename =~ /fixtures/ - } - add_filter "/spec/lib/" + add_group "AugeasProviders Libs", "/lib/augeasproviders/" + add_group "Puppet Types", "/lib/puppet/type/" + add_group "Puppet Providers", "/lib/puppet/provider/" + add_group "Augeas Spec Lib", "/spec/lib/" + + add_filter "/spec/fixtures/" add_filter "/spec/unit/" + add_filter "/spec/support/" end require 'puppetlabs_spec_helper/module_spec_helper' From 8b6d1796362fcdc51b7b9738f39c052a4f1c02ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Pinson?= Date: Wed, 6 Aug 2014 10:42:32 +0200 Subject: [PATCH 18/29] Add badges to README.md --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 13c53df..dbdfe13 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,6 @@ +[![Build Status](https://travis-ci.org/hercules-team/augeasproviders.svg?branch=master)](https://travis-ci.org/hercules-team/augeasproviders) +[![Coverage Status](https://img.shields.io/coveralls/hercules-team/augeasproviders.svg)](https://coveralls.io/r/hercules-team/augeasproviders?branch=master) + # augeasproviders\_core: library for building alternative Augeas-based providers for Puppet This module provides a library for module authors to create new types and From 55de74a1cb6b0c93ebaf11ca41e9192d1f5fd221 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Pinson?= Date: Wed, 6 Aug 2014 12:24:10 +0200 Subject: [PATCH 19/29] Disable coveralls for Ruby 1.8 builds --- Gemfile | 3 ++- spec/spec_helper.rb | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Gemfile b/Gemfile index f77b35d..dff3d52 100644 --- a/Gemfile +++ b/Gemfile @@ -32,5 +32,6 @@ group :development do gem 'beaker', :require => false, :git => 'https://github.com/puppetlabs/beaker', :ref => 'dbac20fe9' gem 'beaker-rspec', :require => false gem 'vagrant-wrapper', :require => false - gem 'coveralls' + + gem 'coveralls' unless RUBY_VERSION =~ /^1\.8/ end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index d5f3bc3..2e9beb2 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -6,7 +6,7 @@ require 'simplecov' require 'coveralls' -SimpleCov.formatter = Coveralls::SimpleCov::Formatter +SimpleCov.formatter = Coveralls::SimpleCov::Formatter unless RUBY_VERSION =~ /^1\.8/ SimpleCov.start do add_group "AugeasProviders Libs", "/lib/augeasproviders/" add_group "Puppet Types", "/lib/puppet/type/" From 23a3f84f6590fab35d20a5abb014aa8a2a089678 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Pinson?= Date: Wed, 6 Aug 2014 13:38:36 +0200 Subject: [PATCH 20/29] Do not require coveralls on Ruby 1.8 --- spec/spec_helper.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 2e9beb2..d961e9a 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -5,8 +5,10 @@ require 'rubygems' require 'simplecov' -require 'coveralls' -SimpleCov.formatter = Coveralls::SimpleCov::Formatter unless RUBY_VERSION =~ /^1\.8/ +unless RUBY_VERSION =~ /^1\.8/ + require 'coveralls' + SimpleCov.formatter = Coveralls::SimpleCov::Formatter +end SimpleCov.start do add_group "AugeasProviders Libs", "/lib/augeasproviders/" add_group "Puppet Types", "/lib/puppet/type/" From 2cc9d65ecf769c054fb254c9626679461335da73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Pinson?= Date: Thu, 7 Aug 2014 12:11:49 +0200 Subject: [PATCH 21/29] Add puppet and mounttab --- .fixtures.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.fixtures.yml b/.fixtures.yml index 881fab8..1a02cde 100644 --- a/.fixtures.yml +++ b/.fixtures.yml @@ -7,12 +7,16 @@ fixtures: repo: git://github.com/hercules-team/augeasproviders_apache.git augeasproviders_grub: repo: git://github.com/hercules-team/augeasproviders_grub.git + augeasproviders_mounttab: + repo: git://github.com/hercules-team/augeasproviders_mounttab.git augeasproviders_nagios: repo: git://github.com/hercules-team/augeasproviders_nagios.git augeasproviders_pam: repo: git://github.com/hercules-team/augeasproviders_pam.git augeasproviders_postgresql: repo: git://github.com/hercules-team/augeasproviders_postgresql.git + augeasproviders_puppet: + repo: git://github.com/hercules-team/augeasproviders_puppet.git augeasproviders_shellvar: repo: git://github.com/hercules-team/augeasproviders_shellvar.git augeasproviders_ssh: From 174287adf6a05c48cac506eb3ffdcbc56820f5c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Pinson?= Date: Thu, 7 Aug 2014 14:48:26 +0200 Subject: [PATCH 22/29] mounttab requires mount_providers --- .fixtures.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.fixtures.yml b/.fixtures.yml index 1a02cde..226d8ca 100644 --- a/.fixtures.yml +++ b/.fixtures.yml @@ -7,6 +7,9 @@ fixtures: repo: git://github.com/hercules-team/augeasproviders_apache.git augeasproviders_grub: repo: git://github.com/hercules-team/augeasproviders_grub.git + mount_providers: + repo: git://github.com/puppetlabs/puppetlabs-mount_providers.git + ref: 0.0.2 augeasproviders_mounttab: repo: git://github.com/hercules-team/augeasproviders_mounttab.git augeasproviders_nagios: From 7897ca9ef4752eda892fab6d03e54c08da26c88b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Pinson?= Date: Thu, 7 Aug 2014 15:00:12 +0200 Subject: [PATCH 23/29] Remove Modulefile, update metadata.json --- Modulefile | 12 ------------ metadata.json | 26 ++++++++++++++------------ 2 files changed, 14 insertions(+), 24 deletions(-) delete mode 100644 Modulefile diff --git a/Modulefile b/Modulefile deleted file mode 100644 index 3527e1f..0000000 --- a/Modulefile +++ /dev/null @@ -1,12 +0,0 @@ -name 'herculesteam-augeasproviders_core' -version '1.1.0' -source 'git://github.com/hercules-team/augeasproviders_core' -author 'Dominic Cleal, Raphael Pinson' -license 'Apache 2.0' -summary 'Alternative Augeas-based providers for Puppet' -description 'This module provides alternative providers for core Puppet types using the Augeas configuration API library.' -project_page 'http://augeasproviders.com' -dependency 'puppetlabs/stdlib', '>=3.2.0 <5.0.0' - -## Add dependencies, if any: -# dependency 'puppetlabs/mount_providers' diff --git a/metadata.json b/metadata.json index 8ce7797..35b868f 100644 --- a/metadata.json +++ b/metadata.json @@ -1,12 +1,14 @@ -/* -+-----------------------------------------------------------------------+ -| | -| ==> DO NOT EDIT THIS FILE! <== | -| | -| You should edit the `Modulefile` and run `puppet-module build` | -| to generate the `metadata.json` file for your releases. | -| | -+-----------------------------------------------------------------------+ -*/ - -{} +{ + "name": "herculesteam-augeasproviders_core", + "version": "1.1.0", + "author": "Dominic Cleal, Raphael Pinson", + "summary": "Alternative Augeas-based providers for Puppet", + "license": "Apache 2.0", + "source": "git://github.com/hercules-team/augeasproviders_core", + "project_page": "http://augeasproviders.com", + "issues_url": "https://github.com/hercules-team/augeasproviders_core/issues", + "description": "This module provides alternative providers for core Puppet types using the Augeas configuration API library.", + "dependencies": [ + {"name":"puppetlabs/stdlib","version_requirement":">=3.2.0 <5.0.0"} + ] +} From 89008a92f09d99f585b6a46ea10514bd3683ee00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Pinson?= Date: Thu, 7 Aug 2014 15:47:58 +0200 Subject: [PATCH 24/29] Cleanup things that went into the core repository --- .fixtures.yml | 2 + lib/puppet/provider/augeasprovider/default.rb | 938 ------------------ lib/puppet/type/augeasprovider.rb | 5 - .../provider/augeasprovider/default/broken | 1 - .../provider/augeasprovider/default/full | 4 - spec/lib/augeas_spec.rb | 18 - spec/lib/augeas_spec/augparse.rb | 81 -- spec/lib/augeas_spec/fixtures.rb | 78 -- spec/spec_helper.rb | 2 +- .../provider/augeasprovider/default_spec.rb | 659 ------------ 10 files changed, 3 insertions(+), 1785 deletions(-) delete mode 100644 lib/puppet/provider/augeasprovider/default.rb delete mode 100644 lib/puppet/type/augeasprovider.rb delete mode 100644 spec/fixtures/unit/puppet/provider/augeasprovider/default/broken delete mode 100644 spec/fixtures/unit/puppet/provider/augeasprovider/default/full delete mode 100644 spec/lib/augeas_spec.rb delete mode 100644 spec/lib/augeas_spec/augparse.rb delete mode 100644 spec/lib/augeas_spec/fixtures.rb delete mode 100755 spec/unit/puppet/provider/augeasprovider/default_spec.rb diff --git a/.fixtures.yml b/.fixtures.yml index 226d8ca..5985d6b 100644 --- a/.fixtures.yml +++ b/.fixtures.yml @@ -3,6 +3,8 @@ fixtures: stdlib: repo: git://github.com/puppetlabs/puppetlabs-stdlib.git ref: 4.1.0 + augeasproviders_core: + repo: git://github.com/hercules-team/augeasproviders_core.git augeasproviders_apache: repo: git://github.com/hercules-team/augeasproviders_apache.git augeasproviders_grub: diff --git a/lib/puppet/provider/augeasprovider/default.rb b/lib/puppet/provider/augeasprovider/default.rb deleted file mode 100644 index 95fceee..0000000 --- a/lib/puppet/provider/augeasprovider/default.rb +++ /dev/null @@ -1,938 +0,0 @@ -require 'augeas' if Puppet.features.augeas? - -# Base Augeas provider -# Handles basics such as opening, accessing and saving changes via an Augeas -# handle, plus standard configuration from a Puppet resource (e.g. the `target` -# parameter). -# -# To use, include as parent provider: -# -# Puppet::Type.type(:example).provide( -# :augeas, -# :parent => Puppet::Type.type(:augeasprovider).provider(:default) -# ) do -# # [..] -# end -# -Puppet::Type.type(:augeasprovider).provide(:default) do - # Class methods automatically added to a Puppet provider by including the - # {AugeasProviders::Provider} mixin. - - # Returns the Augeas version used - # - # @return [String] Augeas version in use - # @api public - def self.aug_version - @aug_version ||= Augeas.open(nil, nil, Augeas::NO_MODL_AUTOLOAD) { |aug| aug.get('/augeas/version') } - end - - # Returns whether a feature is supported. - # - # The following features are currently supported: - # - # * `:regexpi`: whether Augeas supports an 'i' flag in regexp expressions - # * `:post_resource_eval`: whether Puppet supports `post_resource_eval` hooks - # - # @param [Symbol] feature the feature to check - # @return [Boolean] whether feature is supported - # @api public - def self.supported?(feature) - case feature - when :regexpi - Puppet::Util::Package.versioncmp(aug_version, '1.0.0') >= 0 - when :post_resource_eval - Puppet::Util::Package.versioncmp(Puppet.version, '3.4.0') >= 0 - else - raise Puppet::Error, "Unknown feature '#{feature}'" - end - end - - # Returns a node label to use for creating a new entry in an Augeas sequence - # (seq), given the current list, e.g. '1' if it's the first. Supply - # aug.match('$target/*') or similar. - # - # @param [Array] existing paths, from Augeas#match - # @return [String] new node label - def self.next_seq(matches) - last = matches.map {|p| path_label(nil, p).to_i }.max || 0 - (last + 1).to_s - end - - # Returns an Augeas handler. - # - # On Puppet >= 3.4, stores and returns a shared Augeas handler - # for all instances of the class - # - # @return [Augeas] Augeas shared Augeas handle - # @api private - def self.aug_handler - if supported?(:post_resource_eval) - @aug ||= Augeas.open(nil, loadpath, Augeas::NO_MODL_AUTOLOAD) - else - Augeas.open(nil, loadpath, Augeas::NO_MODL_AUTOLOAD) - end - end - - # Close the shared Augeas handler. - # - # @param [Augeas] aug open Augeas handle - # @api public - def self.augclose!(aug) - aug.close - end - - # Opens Augeas and returns a handle to use. It loads only the file - # identified by {#target} (and the supplied `resource`) using {#lens}. - # - # If called with a block, this will be yielded to and the Augeas handle - # closed after the block has executed (on Puppet < 3.4.0). - # Otherwise, the handle will be returned and not closed automatically. - # On Puppet >= 3.4, the handle will be closed by `post_resource_eval`. - # On older versions, the caller is responsible for closing it to free - # resources. - # - # If `yield_resource` is set to true, the supplied `resource` will be passed - # as a yieldparam to the block, after the `aug` handle. Any arguments passed - # after `yield_resource` will be added as yieldparams to the block. - # - # @param [Puppet::Resource] resource resource being evaluated - # @param [Boolean] yield_resource whether to send `resource` as a yieldparam - # @param [Splat] yield_params a splat of parameters to pass as yieldparams if `yield_resource` is true - # @return [Augeas] Augeas handle if no block is given - # @yield [aug, resource, *yield_params] block that uses the Augeas handle - # @yieldparam [Augeas] aug open Augeas handle - # @yieldparam [Puppet::Resource] resource the supplied Puppet resource, passed if `yield_resource` is set to true - # @yieldparam [Splat] *yield_params a splat of additional arguments sent to the block, if `yield_resource` is set to true - # @raise [Puppet::Error] if Augeas did not load the file - # @api public - def self.augopen(resource = nil, yield_resource = false, *yield_params, &block) - augopen_internal(resource, false, yield_resource, *yield_params, &block) - end - - # Opens Augeas and returns a handle to use. It loads only the file - # for the current Puppet resource using {AugeasProviders::Provider::ClassMethods#lens}. - # #augsave! is called after the block is evaluated. - # - # If called with a block, this will be yielded to and the Augeas handle - # closed after the block has executed (on Puppet < 3.4.0). - # Otherwise, the handle will be returned and not closed automatically. - # On Puppet >= 3.4, the handle will be closed by `post_resource_eval`. - # On older versions, the caller is responsible for closing it to free - # resources. - # - # If `yield_resource` is set to true, the supplied `resource` will be passed - # as a yieldparam to the block, after the `aug` handle. Any arguments passed - # after `yield_resource` will be added as yieldparams to the block. - # - # @param [Puppet::Resource] resource resource being evaluated - # @param [Boolean] yield_resource whether to send `resource` as a yieldparam - # @param [Splat] yield_params a splat of parameters to pass as yieldparams if `yield_resource` is true - # @return [Augeas] Augeas handle if no block is given - # @yield [aug, resource, *yield_params] block that uses the Augeas handle - # @yieldparam [Augeas] aug open Augeas handle - # @yieldparam [Puppet::Resource] resource the supplied Puppet resource, passed if `yield_resource` is set to true - # @yieldparam [Splat] *yield_params a splat of additional arguments sent to the block, if `yield_resource` is set to true - # @raise [Puppet::Error] if Augeas did not load the file - # @api public - def self.augopen!(resource = nil, yield_resource = false, *yield_params, &block) - augopen_internal(resource, true, yield_resource, *yield_params, &block) - end - - # Saves all changes made in the current Augeas handle and checks for any - # errors while doing so. - # Reloads the tree afterwards to remove specific changes for next resource. - # - # @param [Augeas] aug open Augeas handle - # @param [Boolean] reload whether to reload the tree after saving - # @raise [Augeas::Error] if saving fails - # @api public - def self.augsave!(aug, reload = false) - begin - aug.save! - rescue Augeas::Error - errors = [] - aug.match("/augeas//error").each do |errnode| - aug.match("#{errnode}/*").each do |subnode| - subvalue = aug.get(subnode) - errors << "#{subnode} = #{subvalue}" - end - end - debug("Save failure details:\n" + errors.join("\n")) - raise Augeas::Error, 'Failed to save Augeas tree to file. See debug logs for details.' - ensure - aug.load! if reload - end - end - - # Define a method with a block passed to #augopen - # - # @param [Symbol] method the name of the method to create - # @yield [aug, resource, *args] block that uses the Augeas handle - # @yieldparam [Augeas] aug open Augeas handle - # @yieldparam [Puppet::Resource] resource the supplied Puppet resource - # @yieldparam [Splat] *args a splat of additional arguments sent to the block - # @api public - def self.define_aug_method(method, &block) - define_method(method) do |*args| - # We are calling the resource's augopen here, not the class - augopen(true, *args, &block) - end - end - - # Define a method with a block passed to #augopen! - # - # @param [Symbol] method the name of the method to create - # @yield [aug, resource, *args] block that uses the Augeas handle - # @yieldparam [Augeas] aug open Augeas handle - # @yieldparam [Puppet::Resource] resource the supplied Puppet resource - # @yieldparam [Splat] *args a splat of additional arguments sent to the block - # @api public - def self.define_aug_method!(method, &block) - define_method(method) do |*args| - # We are calling the resource's augopen! here, not the class - augopen!(true, *args, &block) - end - end - - # Defines a property getter with a provided implementation. It works from - # a node identified with the given `label` beneath the resource. - # - # Supports three implementations based on the type specified: - # - # :string causes the getter to return the value of the node below - # resource with the label given in opts - # - # :array causes the getter to return an array of values matching the label. - # If sublabel is given, values of matching nodes beneath the - # label node will be returned in an array. If sublabel is :seq, values of - # nodes matching a numbered seq will be returned. - # - # :hash causes the getter to return a hash of the value of each matching - # label node against the value of each sublabel node. - # - # @param [String] name the name of the property - # @param [Hash] opts the options to create the setter - # @option opts [String] label node label to match beneath resource, default is `name.to_s`. When the value is `:resource`, `$resource` will be used as the path to the node - # @option opts [Symbol] type either :string, :array or :hash - # @option opts [String] default default value for hash values if sublabel doesn't exist - # @option opts [String] sublabel label of next node(s) beneath node label, used in array and hash values, or :seq for array values representing a numbered seq - # @api public - def self.attr_aug_reader(name, opts = {}) - label = opts[:label] || name.to_s - default = opts[:default] || nil - type = opts[:type] || :string - sublabel = opts[:sublabel] || nil - - rpath = label == :resource ? '$resource' : "$resource/#{label}" - - if type == :hash and sublabel.nil? - fail "You must provide a sublabel for type hash" - end - - unless [:string, :array, :hash].include? type - fail "Invalid type: #{type}" - end - - # Class getter method using an existing aug handler - # Emulate define_singleton_method for Ruby 1.8 - metaclass = class << self; self; end - metaclass.send(:define_method, "attr_aug_reader_#{name}") do |aug, *args| - case type - when :string - aug.get(rpath) - when :array - aug.match(rpath).map do |p| - if sublabel.nil? - aug.get(p) - else - if sublabel == :seq - sp = "#{p}/*[label()=~regexp('[0-9]+')]" - else - sp = "#{p}/#{sublabel}" - end - aug.match(sp).map { |sp| aug.get(sp) } - end - end.flatten - when :hash - values = {} - aug.match(rpath).each do |p| - sp = "#{p}/#{sublabel}" - values[aug.get(p)] = aug.get(sp) || default - end - values - end - end - - # Instance getter method for the instance - define_method("attr_aug_reader_#{name}") do |aug, *args| - self.class.send("attr_aug_reader_#{name}", aug, *args) - end - - # We are calling the resource's augopen here, not the class - define_method(name) do |*args| - augopen do |aug| - self.send("attr_aug_reader_#{name}", aug, *args) - end - end - end - - # Defines a property setter using #augopen - # - # @param [String] name the name of the property - # @param [Hash] opts the options to create the setter - # @option opts [String] label node label to match beneath resource, default is `name.to_s`. When the value is `:resource`, `$resource` will be used as the path to the node - # @option opts [Symbol] type either :string, :array or :hash - # @option opts [String] default default value for hash values if sublabel doesn't exist - # @option opts [String] sublabel label of next node(s) beneath node label, used in array and hash values, or :seq for array values representing a numbered seq - # @option opts [Boolean] purge_ident whether to purge other matches (keeps the last one only) - # @option opts [Boolean] rm_node whether setting a string value to `nil` removes the node (default is to clear its value) - # @api public - def self.attr_aug_writer(name, opts = {}) - label = opts[:label] || name.to_s - default = opts[:default] || nil - type = opts[:type] || :string - sublabel = opts[:sublabel] || nil - purge_ident = opts[:purge_ident] || false - rm_node = opts[:rm_node] || false - - rpath = label == :resource ? '$resource' : "$resource/#{label}" - - if type == :hash and sublabel.nil? - fail "You must provide a sublabel for type hash" - end - - unless [:string, :array, :hash].include? type - fail "Invalid type: #{type}" - end - - # Class setter method using an existing aug handler - # Emulate define_singleton_method for Ruby 1.8 - metaclass = class << self; self; end - metaclass.send(:define_method, "attr_aug_writer_#{name}") do |aug, *args| - aug.rm("#{rpath}[position() != 1]") if purge_ident - case type - when :string - if args[0] - aug.set(rpath, args[0]) - elsif rm_node - aug.rm(rpath) - else - aug.clear(rpath) - end - when :array - if args[0].nil? - aug.rm(rpath) - else - if sublabel.nil? - aug.rm(rpath) - count = 0 - args[0].each do |v| - count += 1 - aug.set("#{rpath}[#{count}]", v) - end - elsif sublabel == :seq - # Make sure only our values are used - aug.rm("#{rpath}/*[label()=~regexp('[0-9]+')]") - count = 0 - args[0].each do |v| - count += 1 - aug.set("#{rpath}/#{count}", v) - end - else - # Make sure only our values are used - aug.rm("#{rpath}/#{sublabel}") - count = 0 - args[0].each do |v| - count += 1 - aug.set("#{rpath}/#{sublabel}[#{count}]", v) - end - end - end - when :hash - # First get rid of all entries - aug.rm(rpath) - args[0].each do |k, v| - aug.set("#{rpath}[.='#{k}']", k) - unless v == default - aug.set("#{rpath}[.='#{k}']/#{sublabel}", v) - end - end - end - end - - # Instance setter method for the instance - define_method("attr_aug_writer_#{name}") do |aug, *args| - self.class.send("attr_aug_writer_#{name}", aug, *args) - end - - # We are calling the resource's augopen here, not the class - define_method("#{name}=") do |*args| - augopen! do |aug| - self.send("attr_aug_writer_#{name}", aug, *args) - end - end - end - - # Define getter and setter for a property - # - # @param [Symbol] name the name of the property - # @param [Hash] opts the options to create the setter - # @option opts [String] label node label to match beneath resource, default is `name.to_s`. When the value is `:resource`, `$resource` will be used as the path to the node - # @option opts [Symbol] type either :string, :array or :hash - # @option opts [String] default default value for hash values if sublabel doesn't exist - # @option opts [String] sublabel label of next node(s) beneath node label, used in array and hash values, or :seq for array values representing a numbered seq - # @option opts [Boolean] purge_ident whether to purge other matches (keeps the last one only) - # @api public - def self.attr_aug_accessor(name, opts = {}) - attr_aug_reader(name, opts) - attr_aug_writer(name, opts) - end - - # Setter for the default file path managed by the provider. - # - # Takes a block to store, but doesn't yield. Will be called when it's - # needed. - # - # @yield block that identifies the default file path managed by the provider - # @yieldreturn [String] default file path - # @api public - def self.default_file(&block) - @default_file_block = block - end - - # Getter and setter for the Augeas lens used for this provider. - # - # When called with a block, will only store the block - it doesn't yield. - # - # When called without a block, expects `resource` parameter which is - # passed into the block, which returns the lens to be used. - # - # @param resource [Puppet::Resource] required for getter, resource being evaluated - # @yield [resource] block that identifies the lens to use - # @yieldparam [Puppet::Resource] resource resource being evaluted - # @yieldreturn [String] Augeas lens to use, e.g. `'Hosts.lns'` - # @return [String] Augeas lens to use, e.g. `'Hosts.lns'` - # @raise [Puppet::Error] if no block has been set when getting - # @api public - def self.lens(resource = nil, &block) - if block_given? - @lens_block = block - else - fail 'Lens is not provided' unless @lens_block - @lens_block.call(resource) - end - end - - # Wrapper around aug.label for older versions of Augeas - # and values not found in the tree. - # - # @param [Augeas] aug Augeas handler - # @param [String] path expression to get the label from - # @return [String] label of the given path - # @api public - def self.path_label(aug, path) - if aug.respond_to? :label - label = aug.label(path) - end - - # Fallback - label || path.split("/")[-1].split("[")[0] - end - - # Automatically quote a value - # - # @param [String] value the value to quote - # @param [String] oldvalue the optional old value, used to auto-detect existing quoting - # @return [String] the quoted value - # @api public - def self.quoteit(value, resource = nil, oldvalue = nil) - oldquote = readquote oldvalue - - if resource and resource.parameters.include? :quoted - quote = resource[:quoted] - else - quote = :auto - end - - if quote == :auto - quote = if oldquote - oldquote - elsif value =~ /[|&;()<>\s]/ - :double - else - :none - end - end - - case quote - when :double - "\"#{value}\"" - when :single - "'#{value}'" - else - value - end - end - - # Detect what type of quoting a value uses - # - # @param [String] value the value to be analyzed - # @return [Symbol] the type of quoting used (:double, :single or nil) - # @api public - def self.readquote(value) - if value =~ /^(["'])(.*)(?:\1)$/ - case $1 - when '"' then :double - when "'" then :single - else nil end - else - nil - end - end - - # Getter and setter for the Augeas path expression representing an - # individual resource inside a file, that's managed by this provider. - # - # When called with a block, will only store the block - it doesn't yield. - # The block is later used to generate the path expression. - # - # When called without a block, expects `resource` parameter which is - # passed into the block, which returns the path expression representing - # the supplied resource. - # - # If no block has already been set, it returns the path expression - # representing the top-level of the file. - # - # @param resource [Puppet::Resource] required for getter, resource being evaluated - # @yield [resource] block that identifies the path expression - # @yieldparam [Puppet::Resource] resource resource being evaluted - # @yieldreturn [String] Augeas path expression, e.g. `'/files/etc/hosts/1'` - # @return [String] Augeas path expression to use, e.g. `'/files/etc/hosts/1'` - # @raise [Puppet::Error] if no default file block is set and no resource is passed - # @see AugeasProviders::Provider#resource_path - # @see #target - # @api public - def self.resource_path(resource = nil, &block) - if block_given? - @resource_path_block = block - else - if @resource_path_block - path = "/files#{target(resource)}" - @resource_path_block.call(resource) - else - "#{target(resource)}/#{resource[:name]}" - end - end - end - - # Sets useful Augeas variables for the session. - # - # * `$target` points to the root of the target file - # * `$resource` points to path defined by #resource_path - # - # It also sets `/augeas/context` to the target file so - # relative paths can be used, before the variables are set. - # - # If supplied with a resource, it will be used to determine the - # path to the used file. - # - # @param [Augeas] aug Augeas handle - # @param [Puppet::Resource] resource resource being evaluated - # @see #resource_path - # @api public - def self.setvars(aug, resource = nil) - aug.set('/augeas/context', "/files#{target(resource)}") - aug.defnode('target', "/files#{target(resource)}", nil) - aug.defvar('resource', resource_path(resource)) if resource - end - - # Gets the path expression representing the file being managed. - # - # If supplied with a resource, this will represent the file identified by - # the resource, else the default file that the provider manages. - # - # @param [Puppet::Resource] resource resource being evaluated - # @return [String] path expression representing the file being managed - # @raise [Puppet::Error] if no default block is set and no resource is passed - # @see AugeasProviders::Provider#target - # @see #resource_path - # @api public - def self.target(resource = nil) - file = @default_file_block.call if @default_file_block - file = resource[:target] if resource and resource[:target] - fail 'No target file given' if file.nil? - file.chomp('/') - end - - # Automatically unquote a value - # - # @param [String] value the value to unquote - # @return [String] the unquoted value - # @api public - def self.unquoteit(value) - if value =~ /^(["'])(.*)(?:\1)$/ - $2 - else - value - end - end - - # Returns whether text is parsed as path using lens - # - # @param [String] text the text to test - # @param [String] path the relative path to test - # @param [String] lens the lens to use for parsing - # @return [Boolean] whether the path was found when parsing text with lens - # @api public - def self.parsed_as?(text, path, lens) - Augeas.open(nil, nil, Augeas::NO_MODL_AUTOLOAD) do |aug| - if aug.respond_to? :text_store - aug.set('/input', text) - if aug.text_store(lens, '/input', '/parsed') - return aug.match("/parsed/#{path}").any? - end - else - # ruby-augeas < 0.5 doesn't support text_store - Tempfile.open('aug_text_store') do |tmpfile| - tmpfile.write(text) - tmpfile.flush - aug.transform( - :lens => lens, - :name => 'Text_store', - :incl => tmpfile.path.to_s, - :excl => [] - ) - aug.load! - return aug.match("/files#{tmpfile.path.to_s}/#{path}").any? - end - end - end - return false - end - - # Sets the post_resource_eval class hook for Puppet - # This is only used with Puppet > 3.4.0 - # and allows to clean the shared Augeas handler. - def self.post_resource_eval - augclose!(aug_handler) - @aug = nil - end - - # Returns a set of load paths to use when initialising Augeas. - # - # @return [String] colon-separated string of module paths, or nil if defaults are to be used - def self.loadpath - loadpath = nil - plugins = File.join(Puppet[:libdir], 'augeas', 'lenses') - if File.exists?(plugins) - loadpath = loadpath.to_s.split(File::PATH_SEPARATOR).push(plugins).join(File::PATH_SEPARATOR) - end - loadpath - end - - # Opens Augeas and returns a handle to use. It loads only the file - # identified by {#target} (and the supplied `resource`) using {#lens}. - # - # If called with a block, this will be yielded to and the Augeas handle - # closed after the block has executed (on Puppet < 3.4.0). - # Otherwise, the handle will be returned and not closed automatically. - # On Puppet >= 3.4, the handle will be closed by `post_resource_eval`. - # On older versions, the caller is responsible for closing it to free - # resources. - # - # If `yield_resource` is set to true, the supplied `resource` will be passed - # as a yieldparam to the block, after the `aug` handle. Any arguments passed - # after `yield_resource` will be added as yieldparams to the block. - # - # @param [Puppet::Resource] resource resource being evaluated - # @param [Boolean] autosave whether to call augsave! automatically after the block evaluation - # @param [Boolean] yield_resource whether to send `resource` as a yieldparam - # @param [Splat] yield_params a splat of parameters to pass as yieldparams if `yield_resource` is true - # @return [Augeas] Augeas handle if no block is given - # @yield [aug, resource, *yield_params] block that uses the Augeas handle - # @yieldparam [Augeas] aug open Augeas handle - # @yieldparam [Puppet::Resource] resource the supplied Puppet resource, passed if `yield_resource` is set to true - # @yieldparam [Splat] *yield_params a splat of additional arguments sent to the block, if `yield_resource` is set to true - # @raise [Puppet::Error] if Augeas did not load the file - # @api private - def self.augopen_internal(resource = nil, autosave = false, yield_resource = false, *yield_params, &block) - aug = aug_handler - file = target(resource) - begin - lens_name = lens[/[^\.]+/] - if aug.match("/augeas/load/#{lens_name}").empty? - aug.transform( - :lens => lens, - :name => lens_name, - :incl => file, - :excl => [] - ) - aug.load! - elsif aug.match("/augeas/load/#{lens_name}/incl[.='#{file}']").empty? - # Only add missing file - aug.set("/augeas/load/#{lens_name}/incl[.='#{file}']", file) - aug.load! - end - - if File.exist?(file) && aug.match("/files#{file}").empty? - message = aug.get("/augeas/files#{file}/error/message") - unless aug.match("/augeas/files#{file}/error/pos").empty? - line = aug.get("/augeas/files#{file}/error/line") - char = aug.get("/augeas/files#{file}/error/char") - message += " (line:#{line}, character:#{char})" - end - from = loadpath.nil? ? '' : " from #{loadpath}" - fail("Augeas didn't load #{file} with #{lens}#{from}: #{message}") - end - - if block_given? - setvars(aug, resource) - if yield_resource - block.call(aug, resource, *yield_params) - else - block.call(aug) - end - else - aug - end - rescue - autosave = false - raise - ensure - if aug && block_given? && !supported?(:post_resource_eval) - augsave!(aug) if autosave - augclose!(aug) - end - end - end - - # Returns the Augeas version used - # - # @return [String] Augeas version in use - # @api public - def aug_version - self.class.aug_version - end - - # Returns whether a feature is supported. - # - # The following features are currently supported: - # - # * `:regexpi`: whether Augeas supports an 'i' flag in regexp expressions - # * `:post_resource_eval`: whether Puppet supports `post_resource_eval` hooks - # - # @param [Symbol] feature the feature to check - # @return [Boolean] whether feature is supported - # @api public - def supported?(feature) - self.class.supported?(feature) - end - - # Opens Augeas and returns a handle to use. It loads only the file - # for the current Puppet resource using {AugeasProviders::Provider::ClassMethods#lens}. - # - # If called with a block, this will be yielded to and the Augeas handle - # closed after the block has executed (on Puppet < 3.4.0). - # Otherwise, the handle will be returned and not closed automatically. - # On Puppet >= 3.4, the handle will be closed by `post_resource_eval`. - # On older versions, the caller is responsible for closing it to free - # resources. - # - # If `yield_resource` is set to true, the supplied `resource` will be passed - # as a yieldparam to the block, after the `aug` handle. Any arguments passed - # after `yield_resource` will be added as yieldparams to the block. - # - # @return [Augeas] Augeas handle if no block is given - # @yield [aug, resource, *yield_params] block that uses the Augeas handle - # @yieldparam [Augeas] aug open Augeas handle - # @yieldparam [Puppet::Resource] resource the supplied Puppet resource, passed if `yield_resource` is set to true - # @yieldparam [Splat] *yield_params a splat of additional arguments sent to the block, if `yield_resource` is set to true - # @raise [Puppet::Error] if Augeas did not load the file - # @api public - def augopen(yield_resource = false, *yield_params, &block) - self.class.augopen(self.resource, yield_resource, *yield_params, &block) - end - - # Opens Augeas and returns a handle to use. It loads only the file - # for the current Puppet resource using {AugeasProviders::Provider::ClassMethods#lens}. - # #augsave! is called after the block is evaluated. - # - # If called with a block, this will be yielded to and the Augeas handle - # closed after the block has executed (on Puppet < 3.4.0). - # Otherwise, the handle will be returned and not closed automatically. - # On Puppet >= 3.4, the handle will be closed by `post_resource_eval`. - # On older versions, the caller is responsible for closing it to free - # resources. - # - # @return [Augeas] Augeas handle if no block is given - # @yield [aug, resource, *yield_params] block that uses the Augeas handle - # @yieldparam [Augeas] aug open Augeas handle - # @yieldparam [Puppet::Resource] resource the supplied Puppet resource, passed if `yield_resource` is set to true - # @yieldparam [Splat] *yield_params a splat of additional arguments sent to the block, if `yield_resource` is set to true - # @raise [Puppet::Error] if Augeas did not load the file - # @api public - def augopen!(yield_resource = false, *yield_params, &block) - self.class.augopen!(self.resource, yield_resource, *yield_params, &block) - end - - # Saves all changes made in the current Augeas handle and checks for any - # errors while doing so. - # - # @param [Augeas] aug open Augeas handle - # @param [Boolean] reload whether to reload the tree after saving - # @raise [Augeas::Error] if saving fails - # @api public - def augsave!(aug, reload = false) - self.class.augsave!(aug, reload) - end - - # Close the shared Augeas handler. - # - # @param [Augeas] aug open Augeas handle - # @api public - def augclose!(aug) - self.class.augclose!(aug) - end - - # Returns an Augeas handler. - # - # On Puppet >= 3.4, stores and returns a shared Augeas handler - # for all instances of the class - # - # @return [Augeas] Augeas shared Augeas handle - # @api private - def aug_handler - self.class.aug_handler - end - - # Wrapper around Augeas#label for older versions of Augeas - # - # @param [Augeas] aug Augeas handler - # @param [String] path expression to get the label from - # @return [String] label of the given path - # @api public - def path_label(aug, path) - self.class.path_label(aug, path) - end - - # Automatically quote a value - # - # @param [String] value the value to quote - # @param [String] oldvalue the optional old value, used to auto-detect existing quoting - # @return [String] the quoted value - # @api public - def quoteit(value, oldvalue = nil) - self.class.quoteit(value, self.resource, oldvalue) - end - - # Detect what type of quoting a value uses - # - # @param [String] value the value to be analyzed - # @return [Symbol] the type of quoting used (:double, :single or nil) - # @api public - def readquote(value) - self.class.readquote(value) - end - - # Gets the Augeas path expression representing the individual resource inside - # the file, that represents the current Puppet resource. - # - # If no block was set by the provider's class method, it returns the path - # expression representing the top-level of the file. - # - # @return [String] Augeas path expression to use, e.g. `'/files/etc/hosts/1'` - # @see AugeasProviders::Provider::ClassMethods#resource_path - # @see #target - # @api public - def resource_path - self.class.resource_path(self.resource) - end - - # Sets useful Augeas variables for the session: - # - # * `$target` points to the root of the target file - # * `$resource` points to path defined by #resource_path - # - # It also sets `/augeas/context` to the target file so - # relative paths can be used, before the variables are set. - # - # If supplied with a resource, it will be used to determine the - # path to the used file. - # - # @param [Augeas] aug Augeas handle - # @see #resource_path - # @api public - def setvars(aug) - self.class.setvars(aug, self.resource) - end - - # Gets the path expression representing the file being managed for the - # current Puppet resource. - # - # @return [String] path expression representing the file being managed - # @see AugeasProviders::Provider::ClassMethods#target - # @see #resource_path - # @api public - def target - self.class.target(self.resource) - end - - # Automatically unquote a value - # - # @param [String] value the value to unquote - # @return [String] the unquoted value - # @api public - def unquoteit(value) - self.class.unquoteit(value) - end - - # Returns whether text is parsed as path using lens - # - # @param [String] text the text to test - # @param [String] path the relative path to test - # @param [String] lens the lens to use for parsing - # @return [Boolean] whether the path was found when parsing text with lens - # @api public - def parsed_as?(text, path, lens = nil) - lens ||= self.class.lens(self.resource) - self.class.parsed_as?(text, path, lens) - end - - # Default method to determine the existence of a resource - # can be overridden if necessary - def exists? - augopen do |aug| - not aug.match('$resource').empty? - end - end - - # Default method to destroy a resource - # can be overridden if necessary - def destroy - augopen! do |aug| - aug.rm('$resource') - end - end - - # Default method to flush a resource - # - # On Puppet >= 3.4, this takes care of - # saving the tree for the shared Augeas handler. - # - # This method can be overridden in your provider - # but you should make sure to call `super` - # to ensure that the tree will be saved in Puppet >= 3.4 - def flush - augsave!(aug_handler, true) if supported?(:post_resource_eval) - end - - # Returns a node label to use for creating a new entry in an Augeas sequence - # (seq), given the current list, e.g. '1' if it's the first. Supply - # aug.match('$target/*') or similar. - # - # @param [Array] existing paths, from Augeas#match - # @return [String] new node label - def next_seq(matches) - self.class.next_seq(matches) - end -end diff --git a/lib/puppet/type/augeasprovider.rb b/lib/puppet/type/augeasprovider.rb deleted file mode 100644 index 77eded6..0000000 --- a/lib/puppet/type/augeasprovider.rb +++ /dev/null @@ -1,5 +0,0 @@ -# Dumb augeasprovider type - -Puppet::Type.newtype(:augeasprovider) do - @doc = 'Dumb Augeas provider type' -end diff --git a/spec/fixtures/unit/puppet/provider/augeasprovider/default/broken b/spec/fixtures/unit/puppet/provider/augeasprovider/default/broken deleted file mode 100644 index 57f89ed..0000000 --- a/spec/fixtures/unit/puppet/provider/augeasprovider/default/broken +++ /dev/null @@ -1 +0,0 @@ -broken diff --git a/spec/fixtures/unit/puppet/provider/augeasprovider/default/full b/spec/fixtures/unit/puppet/provider/augeasprovider/default/full deleted file mode 100644 index 2a4fb70..0000000 --- a/spec/fixtures/unit/puppet/provider/augeasprovider/default/full +++ /dev/null @@ -1,4 +0,0 @@ -127.0.0.1 localhost.localdomain localhost -::1 localhost6.localdomain6 localhost6 -192.168.0.5 iridium iridium.example.com -192.168.0.10 argon # NAS diff --git a/spec/lib/augeas_spec.rb b/spec/lib/augeas_spec.rb deleted file mode 100644 index 3537989..0000000 --- a/spec/lib/augeas_spec.rb +++ /dev/null @@ -1,18 +0,0 @@ -module AugeasSpec - class Error < StandardError - end -end - -require 'augeas_spec/augparse' -require 'augeas_spec/fixtures' - -RSpec.configure do |config| - config.extend AugeasSpec::Augparse - config.extend AugeasSpec::Fixtures - config.include AugeasSpec::Augparse - config.include AugeasSpec::Fixtures - - config.before :each do - Puppet::Util::Storage.stubs(:store) - end -end diff --git a/spec/lib/augeas_spec/augparse.rb b/spec/lib/augeas_spec/augparse.rb deleted file mode 100644 index b3cb330..0000000 --- a/spec/lib/augeas_spec/augparse.rb +++ /dev/null @@ -1,81 +0,0 @@ -require 'augeas' -require 'tempfile' - -module AugeasSpec::Augparse - # Creates a simple test file, reads in a fixture (that's been modified by - # the provider) and runs augparse against the expected tree. - def augparse(file, lens, result = "?") - Dir.mktmpdir { |dir| - # Augeas always starts with a blank line when creating new files, so - # reprocess file and remove it to make writing tests easier - File.open("#{dir}/input", "w") do |finput| - File.open(file, "r") do |ffile| - line = ffile.readline - finput.write line unless line == "\n" - ffile.each {|line| finput.write line } - end - end - - # Test module, Augeas reads back in the input file - testaug = "#{dir}/test_augeasproviders.aug" - File.open(testaug, "w") { |tf| - tf.write(<&1) - raise AugeasSpec::Error, "augparse failed:\n#{output}" unless $? == 0 && output.empty? - } - end - - # Takes a full fixture file, loads it in Augeas, uses the relative path - # and/or filter and saves just that part in a new file. That's then passed - # into augparse and compared against the expected tree. Saves creating a - # tree of the entire file. - # - # Because the filtered fragment is saved in a new file, seq labels will reset - # too, so it'll be "1" rather than what it was in the original fixture. - def augparse_filter(file, lens, filter, result) - # duplicate the original since we use aug.mv - tmpin = Tempfile.new("original") - tmpin.write(File.read(file)) - tmpin.close - - tmpout = Tempfile.new("filtered") - tmpout.close - - aug_open(tmpin.path, lens) do |aug| - # Load a transform of the target, so Augeas can write into it - aug.transform( - :lens => lens, - :name => lens.split(".")[0], - :incl => tmpout.path, - :excl => [] - ) - aug.load! - tmpaug = "/files#{tmpout.path}" - raise AugeasSpec::Error, "Augeas didn't load empty file #{tmpout.path}" if aug.match(tmpaug).empty? - - # Check the filter matches something and move it - ftmatch = aug.match(filter) - raise AugeasSpec::Error, "Filter #{filter} within #{file} matched #{ftmatch.size} nodes, should match at least one" if ftmatch.empty? - - begin - # Loop on aug_match as path indexes will change as we move nodes - fp = ftmatch.first - aug.mv(fp, "#{tmpaug}/#{fp.split(/\//)[-1]}") - ftmatch = aug.match(filter) - end while not ftmatch.empty? - - aug.save! - end - - augparse(tmpout.path, lens, result) - ensure - tmpin.unlink - tmpout.unlink - end -end diff --git a/spec/lib/augeas_spec/fixtures.rb b/spec/lib/augeas_spec/fixtures.rb deleted file mode 100644 index 551ae5b..0000000 --- a/spec/lib/augeas_spec/fixtures.rb +++ /dev/null @@ -1,78 +0,0 @@ -require 'augeas' -require 'tempfile' - -module AugeasSpec::Fixtures - # Creates a temp file from a given fixture name - # Doesn't explicitly clean up the temp file as we can't evaluate a block with - # "let" or pass the path back via an "around" hook. - def aug_fixture(name) - tmp = Tempfile.new("target") - tmp.write(File.read(my_fixture(name))) - tmp.close - return tmp - end - - # Runs a particular resource via a catalog - def apply(*resources) - catalog = Puppet::Resource::Catalog.new - resources.each do |resource| - catalog.add_resource resource - end - catalog.apply - end - - # Runs a resource and checks for warnings and errors - def apply!(*resources) - txn = apply(*resources) - - # Check for warning+ log messages - loglevels = Puppet::Util::Log.levels[3, 999] - firstlogs = @logs.dup - @logs.select { |log| loglevels.include? log.level and log.message !~ /'modulepath' as a setting/ }.should == [] - - # Check for transaction success after, as it's less informative - txn.any_failed?.should_not be_true - - # Run the exact same resources, but this time ensure there were absolutely - # no changes (as seen by logs) to indicate if it was idempotent or not - @logs.clear - txn_idempotent = apply(*resources) - loglevels = Puppet::Util::Log.levels[2, 999] - againlogs = @logs.select { |log| loglevels.include? log.level } - - againlogs.should eq([]), "expected no change on second run (idempotence check),\n got: #{againlogs.inspect}" - txn_idempotent.any_failed?.should_not be_true, "expected no change on second run (idempotence check), got a resource failure" - - @logs = firstlogs - txn - end - - # Open Augeas on a given file. Used for testing the results of running - # Puppet providers. - def aug_open(file, lens, &block) - aug = Augeas.open(nil, nil, Augeas::NO_MODL_AUTOLOAD) - begin - aug.transform( - :lens => lens, - :name => lens.split(".")[0], - :incl => file, - :excl => [] - ) - aug.set("/augeas/context", "/files#{file}") - aug.load! - raise AugeasSpec::Error, "Augeas didn't load #{file}" if aug.match(".").empty? - yield aug - rescue Augeas::Error - errors = [] - aug.match("/augeas//error").each do |errnode| - aug.match("#{errnode}/*").each do |subnode| - subvalue = aug.get(subnode) - errors << "#{subnode} = #{subvalue}" - end - end - raise AugeasSpec::Error, errors.join("\n") - ensure - aug.close - end - end -end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index d961e9a..c0254bf 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,6 +1,6 @@ require 'pathname' dir = Pathname.new(__FILE__).parent -$LOAD_PATH.unshift(dir, File.join(dir, 'lib'), File.join(dir, '..', 'lib')) +$LOAD_PATH.unshift(dir, File.join(dir, 'fixtures/modules/augeasproviders_core/spec/lib'), File.join(dir, '..', 'lib')) require 'rubygems' diff --git a/spec/unit/puppet/provider/augeasprovider/default_spec.rb b/spec/unit/puppet/provider/augeasprovider/default_spec.rb deleted file mode 100755 index 28dec34..0000000 --- a/spec/unit/puppet/provider/augeasprovider/default_spec.rb +++ /dev/null @@ -1,659 +0,0 @@ -#!/usr/bin/env rspec - -require 'spec_helper' - -provider_class = Puppet::Type.type(:augeasprovider).provider(:default) - -describe provider_class do - context "empty provider" do - class Empty < provider_class - end - - subject { Empty } - - describe "#lens" do - it "should fail as default lens isn't set" do - subject.expects(:fail).with('Lens is not provided').raises - expect { subject.lens }.to raise_error - end - end - - describe "#target" do - it "should fail if no default or resource file" do - subject.expects(:fail).with('No target file given').raises - expect { subject.target }.to raise_error - end - - it "should return resource file if set" do - subject.target(:target => '/foo').should == '/foo' - end - - it "should strip trailing / from resource file" do - subject.target(:target => '/foo/').should == '/foo' - end - end - - describe "#resource_path" do - it "should call #target if no resource path block set" do - resource = { :name => 'foo' } - subject.expects(:target).with(resource) - subject.resource_path(resource).should == '/foo' - end - - it "should call #target if a resource path block is set" do - resource = { :name => 'foo' } - subject.expects(:target).with(resource) - subject.resource_path { '/files/test' } - subject.resource_path(resource).should == '/files/test' - end - end - - describe "#readquote" do - it "should return :double when value is double-quoted" do - subject.readquote('"foo"').should == :double - end - - it "should return :single when value is single-quoted" do - subject.readquote("'foo'").should == :single - end - - it "should return nil when value is not quoted" do - subject.readquote("foo").should be_nil - end - - it "should return nil when value is not properly quoted" do - subject.readquote("'foo").should be_nil - subject.readquote("'foo\"").should be_nil - subject.readquote("\"foo").should be_nil - subject.readquote("\"foo'").should be_nil - end - end - - describe "#quoteit" do - it "should not do anything by default for alphanum values" do - subject.quoteit('foo').should == 'foo' - end - - it "should double-quote by default for values containing spaces or special characters" do - subject.quoteit('foo bar').should == '"foo bar"' - subject.quoteit('foo&bar').should == '"foo&bar"' - subject.quoteit('foo;bar').should == '"foo;bar"' - subject.quoteit('foobar').should == '"foo>bar"' - subject.quoteit('foo(bar').should == '"foo(bar"' - subject.quoteit('foo)bar').should == '"foo)bar"' - subject.quoteit('foo|bar').should == '"foo|bar"' - end - - it "should call #readquote and use its value when oldvalue is passed" do - subject.quoteit('foo', nil, "'bar'").should == "'foo'" - subject.quoteit('foo', nil, '"bar"').should == '"foo"' - subject.quoteit('foo', nil, 'bar').should == 'foo' - subject.quoteit('foo bar', nil, "'bar'").should == "'foo bar'" - end - - it "should double-quote special values when oldvalue is not quoted" do - subject.quoteit('foo bar', nil, 'bar').should == '"foo bar"' - end - - it "should use the :quoted parameter when present" do - resource = { } - resource.stubs(:parameters).returns([:quoted]) - - resource[:quoted] = :single - subject.quoteit('foo', resource).should == "'foo'" - - resource[:quoted] = :double - subject.quoteit('foo', resource).should == '"foo"' - - resource[:quoted] = :auto - subject.quoteit('foo', resource).should == 'foo' - subject.quoteit('foo bar', resource).should == '"foo bar"' - end - end - - describe "#unquoteit" do - it "should not do anything when value is not quoted" do - subject.unquoteit('foo bar').should == 'foo bar' - end - - it "should not do anything when value is badly quoted" do - subject.unquoteit('"foo bar').should == '"foo bar' - subject.unquoteit("'foo bar").should == "'foo bar" - subject.unquoteit("'foo bar\"").should == "'foo bar\"" - end - - it "should return unquoted value" do - subject.unquoteit('"foo bar"').should == 'foo bar' - subject.unquoteit("'foo bar'").should == 'foo bar' - end - end - - describe "#parsed_as?" do - context "when text_store is supported" do - it "should return false when text_store fails" do - Augeas.any_instance.expects(:respond_to?).with(:text_store).returns(true) - Augeas.any_instance.expects(:set).with('/input', 'foo').returns(nil) - Augeas.any_instance.expects(:text_store).with('Baz.lns', '/input', '/parsed').returns(false) - subject.parsed_as?('foo', 'bar', 'Baz.lns').should == false - end - - it "should return false when path is not found" do - Augeas.any_instance.expects(:respond_to?).with(:text_store).returns(true) - Augeas.any_instance.expects(:set).with('/input', 'foo').returns(nil) - Augeas.any_instance.expects(:text_store).with('Baz.lns', '/input', '/parsed').returns(true) - Augeas.any_instance.expects(:match).with('/parsed/bar').returns([]) - subject.parsed_as?('foo', 'bar', 'Baz.lns').should == false - end - - it "should return true when path is found" do - Augeas.any_instance.expects(:respond_to?).with(:text_store).returns(true) - Augeas.any_instance.expects(:set).with('/input', 'foo').returns(nil) - Augeas.any_instance.expects(:text_store).with('Baz.lns', '/input', '/parsed').returns(true) - Augeas.any_instance.expects(:match).with('/parsed/bar').returns(['/parsed/bar']) - subject.parsed_as?('foo', 'bar', 'Baz.lns').should == true - end - end - - context "when text_store is not supported" do - it "should return true if path is found in tempfile" do - Augeas.any_instance.expects(:respond_to?).with(:text_store).returns(false) - Augeas.any_instance.expects(:text_store).never - Augeas.any_instance.expects(:match).returns(['/files/tmp/aug_text_store20140410-8734-icc4xn/bar']) - subject.parsed_as?('foo', 'bar', 'Baz.lns').should == true - end - end - end - - describe "#attr_aug_reader" do - it "should create a class method" do - subject.attr_aug_reader(:foo, {}) - subject.method_defined?('attr_aug_reader_foo').should be_true - end - end - - describe "#attr_aug_writer" do - it "should create a class method" do - subject.attr_aug_writer(:foo, {}) - subject.method_defined?('attr_aug_writer_foo').should be_true - end - end - - describe "#attr_aug_accessor" do - it "should call #attr_aug_reader and #attr_aug_writer" do - name = :foo - opts = { :bar => 'baz' } - subject.expects(:attr_aug_reader).with(name, opts) - subject.expects(:attr_aug_writer).with(name, opts) - subject.attr_aug_accessor(name, opts) - end - end - - describe "#next_seq" do - it "should return 1 with no paths" do - subject.new.next_seq([]).should == '1' - end - - it "should return 1 with only comments" do - subject.new.next_seq(['/files/etc/hosts/#comment[1]']).should == '1' - end - - it "should return 2 when 1 exists" do - subject.new.next_seq(['/files/etc/hosts/1']).should == '2' - end - - it "should return 42 when 1..41 exists" do - subject.new.next_seq((1..41).map {|n| "/files/etc/hosts/#{n}"}).should == '42' - end - end - end - - context "working provider" do - class Test < provider_class - lens { 'Hosts.lns' } - default_file { '/foo' } - resource_path { |r, p| r[:test] } - attr_accessor :resource - end - - subject { Test } - let(:tmptarget) { aug_fixture("full") } - let(:thetarget) { tmptarget.path } - let(:resource) { {:target => thetarget} } - - # Class methods - describe "#lens" do - it "should allow retrieval of the set lens" do - subject.lens.should == 'Hosts.lns' - end - end - - describe "#target" do - it "should allow retrieval of the set default file" do - subject.target.should == '/foo' - end - end - - describe "#resource_path" do - it "should call block to get the resource path" do - subject.resource_path(:test => 'bar').should == 'bar' - end - end - - describe "#loadpath" do - it "should return nil by default" do - subject.send(:loadpath).should be_nil - end - - it "should add libdir/augeas/lenses/ to the loadpath if it exists" do - plugindir = File.join(Puppet[:libdir], 'augeas', 'lenses') - File.expects(:exists?).with(plugindir).returns(true) - subject.send(:loadpath).should == plugindir - end - end - - describe "#augopen" do - before do - subject.expects(:augsave!).never - end - - context "on Puppet < 3.4.0" do - before :each do - subject.stubs(:supported?).with(:post_resource_eval).returns(false) - end - - it "should call Augeas#close when given a block" do - subject.augopen(resource) do |aug| - aug.expects(:close) - end - end - - it "should not call Augeas#close when not given a block" do - Augeas.any_instance.expects(:close).never - aug = subject.augopen(resource) - end - end - - context "on Puppet >= 3.4.0" do - before :each do - subject.stubs(:supported?).with(:post_resource_eval).returns(true) - end - - it "should not call Augeas#close when given a block" do - Augeas.any_instance.expects(:close).never - aug = subject.augopen(resource) - end - - it "should not call Augeas#close when not given a block" do - Augeas.any_instance.expects(:close).never - aug = subject.augopen(resource) - end - - it "should call Augeas#close when calling post_resource_eval" do - subject.augopen(resource) do |aug| - aug.expects(:close) - subject.post_resource_eval - end - end - end - - it "should call #setvars when given a block" do - subject.expects(:setvars) - subject.augopen(resource) { |aug| } - end - - it "should not call #setvars when not given a block" do - subject.expects(:setvars).never - aug = subject.augopen(resource) - end - - context "with broken file" do - let(:tmptarget) { aug_fixture("broken") } - - it "should fail if the file fails to load" do - subject.expects(:fail).with(regexp_matches(/Augeas didn't load #{Regexp.escape(thetarget)} with Hosts.lns: Iterated lens matched less than it should/)).raises - expect { subject.augopen(resource) {} }.to raise_error - end - end - end - - describe "#augopen!" do - context "on Puppet < 3.4.0" do - before :each do - subject.stubs(:supported?).with(:post_resource_eval).returns(false) - end - - it "should call Augeas#close when given a block" do - subject.augopen!(resource) do |aug| - aug.expects(:close) - end - end - - it "should not call Augeas#close when not given a block" do - Augeas.any_instance.expects(:close).never - aug = subject.augopen!(resource) - end - end - - context "on Puppet >= 3.4.0" do - before :each do - subject.stubs(:supported?).with(:post_resource_eval).returns(true) - end - - it "should not call Augeas#close when given a block" do - Augeas.any_instance.expects(:close).never - aug = subject.augopen!(resource) - end - - it "should not call Augeas#close when not given a block" do - Augeas.any_instance.expects(:close).never - aug = subject.augopen!(resource) - end - end - - it "should call #setvars when given a block" do - subject.expects(:setvars) - subject.augopen!(resource) { |aug| } - end - - it "should not call #setvars when not given a block" do - subject.expects(:setvars).never - aug = subject.augopen!(resource) - end - - context "on Puppet < 3.4.0" do - before :each do - subject.stubs(:supported?).with(:post_resource_eval).returns(false) - end - - it "should call #augsave when given a block" do - subject.expects(:augsave!) - subject.augopen!(resource) { |aug| } - end - - it "should not call #augsave when not given a block" do - subject.expects(:augsave!).never - aug = subject.augopen!(resource) - end - end - - context "on Puppet >= 3.4.0" do - before :each do - subject.stubs(:supported?).with(:post_resource_eval).returns(true) - end - - it "should not call #augsave when given a block" do - subject.expects(:augsave!).never - subject.augopen!(resource) { |aug| } - end - - it "should not call #augsave when not given a block" do - subject.expects(:augsave!).never - aug = subject.augopen!(resource) - end - - it "should call Augeas#close when calling post_resource_eval" do - subject.augopen(resource) do |aug| - aug.expects(:close) - subject.post_resource_eval - end - end - end - - context "with broken file" do - let(:tmptarget) { aug_fixture("broken") } - - it "should fail if the file fails to load" do - subject.expects(:fail).with(regexp_matches(/Augeas didn't load #{Regexp.escape(thetarget)} with Hosts.lns: Iterated lens matched less than it should/)).raises - expect { subject.augopen!(resource) {} }.to raise_error - end - end - - context "when raising an exception in the block" do - it "should to raise the right exception" do - expect { - subject.augopen! do |aug| - raise Puppet::Error, "My error" - end - }.to raise_error Puppet::Error, "My error" - end - end - end - - describe "#augsave" do - it "should print /augeas//error on save" do - subject.augopen(resource) do |aug| - # Prepare an invalid save - subject.stubs(:debug) - aug.rm("/files#{thetarget}/*/ipaddr").should_not == 0 - lambda { subject.augsave!(aug) }.should raise_error Augeas::Error, /Failed to save Augeas tree/ - end - end - end - - describe "#path_label" do - it "should use Augeas#label when available" do - subject.augopen(resource) do |aug| - aug.expects(:respond_to?).with(:label).returns true - aug.expects(:label).with('/files/foo[2]').returns 'foo' - subject.path_label(aug, '/files/foo[2]').should == 'foo' - end - end - - it "should emulate Augeas#label when it is not available" do - subject.augopen(resource) do |aug| - aug.expects(:respond_to?).with(:label).returns false - aug.expects(:label).with('/files/bar[4]').never - subject.path_label(aug, '/files/bar[4]').should == 'bar' - end - end - - it "should emulate Augeas#label when no label is found in the tree" do - subject.augopen(resource) do |aug| - aug.expects(:respond_to?).with(:label).returns true - aug.expects(:label).with('/files/baz[15]').returns nil - subject.path_label(aug, '/files/baz[15]').should == 'baz' - end - end - end - - describe "#setvars" do - it "should call Augeas#defnode to set $target, Augeas#defvar to set $resource and Augeas#set to set /augeas/context when resource is passed" do - subject.augopen(resource) do |aug| - aug.expects(:set).with('/augeas/context', "/files#{thetarget}") - aug.expects(:defnode).with('target', "/files#{thetarget}", nil) - subject.expects(:resource_path).with(resource).returns('/files/foo') - aug.expects(:defvar).with('resource', '/files/foo') - subject.setvars(aug, resource) - end - end - - it "should call Augeas#defnode to set $target but not $resource when no resource is passed" do - subject.augopen(resource) do |aug| - aug.expects(:defnode).with('target', '/files/foo', nil) - aug.expects(:defvar).never - subject.setvars(aug) - end - end - end - - describe "#attr_aug_reader" do - it "should create a class method using :string" do - subject.attr_aug_reader(:foo, {}) - subject.method_defined?('attr_aug_reader_foo').should be_true - - Augeas.any_instance.expects(:get).with('$resource/foo').returns('bar') - subject.augopen(resource) do |aug| - subject.attr_aug_reader_foo(aug).should == 'bar' - end - end - - it "should create a class method using :array and no sublabel" do - subject.attr_aug_reader(:foo, { :type => :array }) - subject.method_defined?('attr_aug_reader_foo').should be_true - - rpath = "/files#{thetarget}/test/foo" - subject.augopen(resource) do |aug| - aug.expects(:match).with('$resource/foo').returns(["#{rpath}[1]", "#{rpath}[2]"]) - aug.expects(:get).with("#{rpath}[1]").returns('baz') - aug.expects(:get).with("#{rpath}[2]").returns('bazz') - subject.attr_aug_reader_foo(aug).should == ['baz', 'bazz'] - end - end - - it "should create a class method using :array and a :seq sublabel" do - subject.attr_aug_reader(:foo, { :type => :array, :sublabel => :seq }) - subject.method_defined?('attr_aug_reader_foo').should be_true - - rpath = "/files#{thetarget}/test/foo" - subject.augopen(resource) do |aug| - aug.expects(:match).with('$resource/foo').returns(["#{rpath}[1]", "#{rpath}[2]"]) - aug.expects(:match).with("#{rpath}[1]/*[label()=~regexp('[0-9]+')]").returns(["#{rpath}[1]/1"]) - aug.expects(:get).with("#{rpath}[1]/1").returns('val11') - aug.expects(:match).with("#{rpath}[2]/*[label()=~regexp('[0-9]+')]").returns(["#{rpath}[2]/1", "#{rpath}[2]/2"]) - aug.expects(:get).with("#{rpath}[2]/1").returns('val21') - aug.expects(:get).with("#{rpath}[2]/2").returns('val22') - subject.attr_aug_reader_foo(aug).should == ['val11', 'val21', 'val22'] - end - end - - it "should create a class method using :array and a string sublabel" do - subject.attr_aug_reader(:foo, { :type => :array, :sublabel => 'sl' }) - subject.method_defined?('attr_aug_reader_foo').should be_true - - rpath = "/files#{thetarget}/test/foo" - subject.augopen(resource) do |aug| - aug.expects(:match).with('$resource/foo').returns(["#{rpath}[1]", "#{rpath}[2]"]) - aug.expects(:match).with("#{rpath}[1]/sl").returns(["#{rpath}[1]/sl"]) - aug.expects(:get).with("#{rpath}[1]/sl").returns('val11') - aug.expects(:match).with("#{rpath}[2]/sl").returns(["#{rpath}[2]/sl[1]", "#{rpath}[2]/sl[2]"]) - aug.expects(:get).with("#{rpath}[2]/sl[1]").returns('val21') - aug.expects(:get).with("#{rpath}[2]/sl[2]").returns('val22') - subject.attr_aug_reader_foo(aug).should == ['val11', 'val21', 'val22'] - end - end - - it "should create a class method using :hash and no sublabel" do - expect { - subject.attr_aug_reader(:foo, { :type => :hash, :default => 'deflt' }) - }.to raise_error(RuntimeError, /You must provide a sublabel/) - end - - it "should create a class method using :hash and sublabel" do - subject.attr_aug_reader(:foo, { :type => :hash, :sublabel => 'sl', :default => 'deflt' }) - subject.method_defined?('attr_aug_reader_foo').should be_true - - rpath = "/files#{thetarget}/test/foo" - subject.augopen(resource) do |aug| - aug.expects(:match).with('$resource/foo').returns(["#{rpath}[1]", "#{rpath}[2]"]) - aug.expects(:get).with("#{rpath}[1]").returns('baz') - aug.expects(:get).with("#{rpath}[1]/sl").returns('bazval') - aug.expects(:get).with("#{rpath}[2]").returns('bazz') - aug.expects(:get).with("#{rpath}[2]/sl").returns(nil) - subject.attr_aug_reader_foo(aug).should == { 'baz' => 'bazval', 'bazz' => 'deflt' } - end - end - - it "should create a class method using wrong type" do - expect { - subject.attr_aug_reader(:foo, { :type => :foo }) - }.to raise_error(RuntimeError, /Invalid type: foo/) - end - end - - describe "#attr_aug_writer" do - it "should create a class method using :string" do - subject.attr_aug_writer(:foo, {}) - subject.method_defined?('attr_aug_writer_foo').should be_true - - subject.augopen(resource) do |aug| - aug.expects(:set).with('$resource/foo', 'bar') - subject.attr_aug_writer_foo(aug, 'bar') - aug.expects(:clear).with('$resource/foo') - subject.attr_aug_writer_foo(aug) - end - end - - it "should create a class method using :string with :rm_node" do - subject.attr_aug_writer(:foo, { :rm_node => true }) - subject.method_defined?('attr_aug_writer_foo').should be_true - - subject.augopen(resource) do |aug| - aug.expects(:set).with('$resource/foo', 'bar') - subject.attr_aug_writer_foo(aug, 'bar') - aug.expects(:rm).with('$resource/foo') - subject.attr_aug_writer_foo(aug) - end - end - - it "should create a class method using :array and no sublabel" do - subject.attr_aug_writer(:foo, { :type => :array }) - subject.method_defined?('attr_aug_writer_foo').should be_true - - subject.augopen(resource) do |aug| - aug.expects(:rm).with('$resource/foo') - aug.expects(:set).with('$resource/foo[1]', 'bar') - subject.attr_aug_writer_foo(aug) - aug.expects(:rm).with('$resource/foo') - aug.expects(:set).with('$resource/foo[2]', 'baz') - subject.attr_aug_writer_foo(aug, ['bar', 'baz']) - end - end - - it "should create a class method using :array and a :seq sublabel" do - subject.attr_aug_writer(:foo, { :type => :array, :sublabel => :seq }) - subject.method_defined?('attr_aug_writer_foo').should be_true - - subject.augopen(resource) do |aug| - aug.expects(:rm).with('$resource/foo') - subject.attr_aug_writer_foo(aug) - aug.expects(:rm).with("$resource/foo/*[label()=~regexp('[0-9]+')]") - aug.expects(:set).with('$resource/foo/1', 'bar') - aug.expects(:set).with('$resource/foo/2', 'baz') - subject.attr_aug_writer_foo(aug, ['bar', 'baz']) - end - end - - it "should create a class method using :array and a string sublabel" do - subject.attr_aug_writer(:foo, { :type => :array, :sublabel => 'sl' }) - subject.method_defined?('attr_aug_writer_foo').should be_true - - subject.augopen(resource) do |aug| - aug.expects(:rm).with('$resource/foo') - subject.attr_aug_writer_foo(aug) - aug.expects(:rm).with('$resource/foo/sl') - aug.expects(:set).with('$resource/foo/sl[1]', 'bar') - aug.expects(:set).with('$resource/foo/sl[2]', 'baz') - subject.attr_aug_writer_foo(aug, ['bar', 'baz']) - end - end - - it "should create a class method using :hash and no sublabel" do - expect { - subject.attr_aug_writer(:foo, { :type => :hash, :default => 'deflt' }) - }.to raise_error(RuntimeError, /You must provide a sublabel/) - end - - it "should create a class method using :hash and sublabel" do - subject.attr_aug_writer(:foo, { :type => :hash, :sublabel => 'sl', :default => 'deflt' }) - subject.method_defined?('attr_aug_writer_foo').should be_true - - rpath = "/files#{thetarget}/test/foo" - subject.augopen(resource) do |aug| - aug.expects(:rm).with('$resource/foo') - aug.expects(:set).with("$resource/foo[.='baz']", 'baz') - aug.expects(:set).with("$resource/foo[.='baz']/sl", 'bazval') - aug.expects(:set).with("$resource/foo[.='bazz']", 'bazz') - aug.expects(:set).with("$resource/foo[.='bazz']/sl", 'bazzval').never - subject.attr_aug_writer_foo(aug, { 'baz' => 'bazval', 'bazz' => 'deflt' }) - end - end - - it "should create a class method using wrong type" do - expect { - subject.attr_aug_writer(:foo, { :type => :foo }) - }.to raise_error(RuntimeError, /Invalid type: foo/) - end - end - end -end From fb54f207d56cb1d6f73ca0d50e483a6580f0ee49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Pinson?= Date: Mon, 11 Aug 2014 10:20:34 +0200 Subject: [PATCH 25/29] Add all modules to metadata.json --- metadata.json | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/metadata.json b/metadata.json index 35b868f..b04825c 100644 --- a/metadata.json +++ b/metadata.json @@ -9,6 +9,18 @@ "issues_url": "https://github.com/hercules-team/augeasproviders_core/issues", "description": "This module provides alternative providers for core Puppet types using the Augeas configuration API library.", "dependencies": [ - {"name":"puppetlabs/stdlib","version_requirement":">=3.2.0 <5.0.0"} + { "name": "puppetlabs/stdlib", "version_requirement": ">=3.2.0 <5.0.0" }, + { "name": "herculesteam/augeasproviders_apache" }, + { "name": "herculesteam/augeasproviders_base" }, + { "name": "herculesteam/augeasproviders_grub" }, + { "name": "herculesteam/augeasproviders_mounttab" }, + { "name": "herculesteam/augeasproviders_nagios" }, + { "name": "herculesteam/augeasproviders_pam" }, + { "name": "herculesteam/augeasproviders_postgresql" }, + { "name": "herculesteam/augeasproviders_puppet" }, + { "name": "herculesteam/augeasproviders_shellvar" }, + { "name": "herculesteam/augeasproviders_ssh" }, + { "name": "herculesteam/augeasproviders_sysctl" }, + { "name": "herculesteam/augeasproviders_syslog" } ] } From 084882936e63313a09f8373f21c8e63e1e29cc06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Pinson?= Date: Mon, 11 Aug 2014 10:20:54 +0200 Subject: [PATCH 26/29] Version 2.0.0 --- metadata.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metadata.json b/metadata.json index b04825c..025fb70 100644 --- a/metadata.json +++ b/metadata.json @@ -1,6 +1,6 @@ { "name": "herculesteam-augeasproviders_core", - "version": "1.1.0", + "version": "2.0.0", "author": "Dominic Cleal, Raphael Pinson", "summary": "Alternative Augeas-based providers for Puppet", "license": "Apache 2.0", From 8f82cb90006d19ed63a999c3bcc76d04939ced2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Pinson?= Date: Mon, 11 Aug 2014 10:46:12 +0200 Subject: [PATCH 27/29] Restore Puppet lib loading workarounds --- spec/spec_helper.rb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index c0254bf..95b4c2b 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -25,5 +25,20 @@ Puppet[:modulepath] = File.join(dir, 'fixtures', 'modules') +# There's no real need to make this version dependent, but it helps find +# regressions in Puppet +# +# 1. Workaround for issue #16277 where default settings aren't initialised from +# a spec and so the libdir is never initialised (3.0.x) +# 2. Workaround for 2.7.20 that now only loads types for the current node +# environment (#13858) so Puppet[:modulepath] seems to get ignored +# 3. Workaround for 3.5 where context hasn't been configured yet, +# ticket https://tickets.puppetlabs.com/browse/MODULES-823 +# +ver = Gem::Version.new(Puppet.version.split('-').first) +if Gem::Requirement.new("~> 2.7.20") =~ ver || Gem::Requirement.new("~> 3.0.0") =~ ver || Gem::Requirement.new("~> 3.5") =~ ver + Dir["#{dir}/fixtures/modules/*/lib"].each { |l| $LOAD_PATH.unshift(l) } +end + # Load all shared contexts and shared examples Dir["#{dir}/support/**/*.rb"].sort.each {|f| require f} From e59cd4f5788c995d3af840764d4c0e43af90c9d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Pinson?= Date: Wed, 13 Aug 2014 17:44:44 +0200 Subject: [PATCH 28/29] Update CHANGELOG --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 785c1d6..df98273 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog +## 2.0.0 + +- Use a base type/provider with inheritance to distribute the lib +- Split lib, types and providers into separate modules + ## 1.1.0 - General From 4459f519ccf9bef298ea3e5e72e016f420baa06b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Pinson?= Date: Wed, 13 Aug 2014 17:47:49 +0200 Subject: [PATCH 29/29] Update README --- README.md | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index dbdfe13..7ab2d30 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,11 @@ [![Build Status](https://travis-ci.org/hercules-team/augeasproviders.svg?branch=master)](https://travis-ci.org/hercules-team/augeasproviders) [![Coverage Status](https://img.shields.io/coveralls/hercules-team/augeasproviders.svg)](https://coveralls.io/r/hercules-team/augeasproviders?branch=master) -# augeasproviders\_core: library for building alternative Augeas-based providers for Puppet +# augeasproviders: alternative Augeas-based providers for Puppet -This module provides a library for module authors to create new types and +This module provides is a meta module which gathers all official augeasproviders +modules as dependencies. +Augeasproviders modules provide alternative Augeas-based providers for Puppet providers around config files, using the Augeas configuration library to read and modify them. @@ -11,9 +13,6 @@ The advantage of using Augeas over the default Puppet `parsedfile` implementations is that Augeas will go to great lengths to preserve file formatting and comments, while also failing safely when needed. -If you're a user, you want to see the main augeasproviders project at -[augeasproviders.com](http://augeasproviders.com). - ## Requirements Ensure both Augeas and ruby-augeas 0.3.0+ bindings are installed and working as @@ -67,4 +66,4 @@ See docs/ (run `make`) or [augeasproviders.com](http://augeasproviders.com/docum ## Issues -Please file any issues or suggestions [on GitHub](https://github.com/hercules-team/augeasproviders_core/issues). +Please file any issues or suggestions [on GitHub](https://github.com/hercules-team/augeasproviders/issues).