diff options
author | kwadronaut <kwadronaut@leap.se> | 2018-09-27 01:19:23 +0200 |
---|---|---|
committer | kwadronaut <kwadronaut@leap.se> | 2018-09-27 01:19:23 +0200 |
commit | 0c0a8d7f621912a9d7727c16331923d216921dd1 (patch) | |
tree | 6117b7a81a066453b06893304643b8cadca286ed | |
parent | 27e33591776f0226f78877df350d6a52995265d8 (diff) | |
parent | f0faa776b9cd8c9cfbe16651de2fce6b37df4dfb (diff) |
Merge tag '1.6.1'
54 files changed, 818 insertions, 190 deletions
@@ -5,3 +5,6 @@ spec/fixtures/ .vagrant/ .bundle/ coverage/ +log/ +.*.swp +*~ diff --git a/.puppet-lint.rc b/.puppet-lint.rc index d8f5c59..e09d52f 100644 --- a/.puppet-lint.rc +++ b/.puppet-lint.rc @@ -1,5 +1,5 @@ --fail-on-warnings --relative ---no-80chars +--no-140chars --no-documentation --no-class_inherits_from_params_class-check diff --git a/.travis.yml b/.travis.yml index 777290c..70e0f15 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,20 +1,22 @@ --- language: ruby sudo: false +addons: + apt: + packages: + - libaugeas-dev + sources: + - augeas cache: bundler bundler_args: --without system_tests -script: ["bundle exec rake validate", "bundle exec rake lint", "bundle exec rake spec SPEC_OPTS='--format documentation'", "bundle exec rake metadata"] +script: ["bundle exec rake validate", "bundle exec rake lint", "bundle exec rake spec SPEC_OPTS='--format documentation'"] matrix: fast_finish: true include: - - rvm: 1.8.7 - env: PUPPET_GEM_VERSION="~> 3.0" FACTER_GEM_VERSION="~> 1.7.0" - - rvm: 1.9.3 - env: PUPPET_GEM_VERSION="~> 3.0" - - rvm: 2.0.0 - env: PUPPET_GEM_VERSION="~> 3.0" - - rvm: 2.0.0 - env: PUPPET_GEM_VERSION="~> 3.0" FUTURE_PARSER="yes" + - rvm: 2.1.10 + env: PUPPET_GEM_VERSION="~> 4.0" + - rvm: 2.3.4 + env: PUPPET_GEM_VERSION="~> 4" notifications: email: false deploy: @@ -27,4 +29,4 @@ deploy: # all_branches is required to use tags all_branches: true # Only publish if our main Ruby target builds - rvm: 1.9.3 + rvm: 2.1.9 diff --git a/CHANGELOG.md b/CHANGELOG.md index 3bebf66..79bbae8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,99 @@ +## 2017-01-09 - Release 1.6.0 + +- Deprecate Puppet 2 and 3 + +## 2016-08-19 - Release 1.5.1 + +- Fix Travis CI tests + +## 2016-08-18 - Release 1.5.0 + +- Use Augeas PPA for Travis CI tests +- Include augeas 'super' class when not declared (fix #93) + +## 2015-09-09 - Release 1.4.2 + +Fix for puppet AIO packaging + +## 2015-08-31 - Release 1.4.1 + +Fix use of is_pe fact for Puppet open-source + +## 2015-08-31 - Release 1.4.0 + +Add support for Puppet Enterprise paths + +## 2015-08-21 - Release 1.3.1 + +Use docker for acceptance tests + +## 2015-08-12 - Release 1.3.0 + +Add puppet AIO packaging support +Allow setting package name of ruby augeas bindings +Add support for Amazon Linux AMI + +## 2015-06-26 - Release 1.2.13 + +Fix strict_variables activation with rspec-puppet 2.2 + +## 2015-06-24 - Release 1.2.12 + +fix the ruby-augeas gem installation on SLES and openSUSE + +## 2015-05-28 - Release 1.2.11 + +Add beaker_spec_helper to Gemfile + +## 2015-05-26 - Release 1.2.10 + +Use random application order in nodeset + +## 2015-05-26 - Release 1.2.9 + +add utopic & vivid nodesets + +## 2015-05-25 - Release 1.2.8 + +Don't allow failure on Puppet 4 + +## 2015-05-13 - Release 1.2.7 + +Fix source_without_rights warning + +## 2015-05-13 - Release 1.2.6 + +Add puppet-lint-file_source_rights-check gem + +## 2015-05-12 - Release 1.2.5 + +Don't pin beaker + +## 2015-04-27 - Release 1.2.4 + +Add nodeset ubuntu-12.04-x86_64-openstack + +## 2015-04-17 - Release 1.2.3 + +- Add beaker nodesets + +## 2015-04-14 - Release 1.2.2 + +- Fix lens test with content but no source + +## 2015-04-03 - Release 1.2.1 + +- Confine rspec pinning to ruby 1.8 + +## 2015-03-24 - Release 1.2.0 + +- Add lens_content and test_content to augeas::lens +- Fix augeas() function + +## 2015-03-24 - Release 1.1.7 + +- Fix for SUSE + ## 2015-01-19 - Release 1.1.6 - Add puppet-ling plugins @@ -2,28 +2,34 @@ source ENV['GEM_SOURCE'] || "https://rubygems.org" group :development, :unit_tests do gem 'rake', :require => false - gem 'rspec', '~> 3.1.0', :require => false - gem 'rspec-puppet', :require => false, :git => 'https://github.com/camptocamp/rspec-puppet', :branch => 'rspec3' + gem 'rspec', :require => false + gem 'rspec-puppet', :require => false gem 'puppetlabs_spec_helper', :require => false gem 'metadata-json-lint', :require => false gem 'puppet-lint', :require => false gem 'puppet-lint-unquoted_string-check', :require => false gem 'puppet-lint-empty_string-check', :require => false gem 'puppet-lint-spaceship_operator_without_tag-check', :require => false - gem 'puppet-lint-variable_contains_upcase', :require => false gem 'puppet-lint-absolute_classname-check', :require => false gem 'puppet-lint-undef_in_function-check', :require => false gem 'puppet-lint-leading_zero-check', :require => false gem 'puppet-lint-trailing_comma-check', :require => false gem 'puppet-lint-file_ensure-check', :require => false gem 'puppet-lint-version_comparison-check', :require => false + gem 'puppet-lint-file_source_rights-check', :require => false + gem 'puppet-lint-alias-check', :require => false gem 'rspec-puppet-facts', :require => false + gem 'ruby-augeas', :require => false + gem 'puppet-blacksmith', :require => false if RUBY_VERSION !~ /^1\./ + gem 'json_pure', '< 2.0.2', :require => false end group :system_tests do - gem 'beaker', :require => false - gem 'beaker-rspec', :require => false - gem 'serverspec', :require => false + gem 'beaker', :require => false + gem 'beaker-rspec', '> 5', :require => false + gem 'beaker_spec_helper', :require => false + gem 'serverspec', :require => false + gem 'specinfra', :require => false end if facterversion = ENV['FACTER_GEM_VERSION'] @@ -1,7 +1,10 @@ # Augeas Puppet module -[![Puppet Forge](http://img.shields.io/puppetforge/v/camptocamp/augeas.svg)](https://forge.puppetlabs.com/camptocamp/augeas) -[![Build Status](https://travis-ci.org/camptocamp/puppet-augeas.png?branch=master)](https://travis-ci.org/camptocamp/puppet-augeas) +[![Puppet Forge Version](http://img.shields.io/puppetforge/v/camptocamp/augeas.svg)](https://forge.puppetlabs.com/camptocamp/augeas) +[![Puppet Forge Downloads](http://img.shields.io/puppetforge/dt/camptocamp/augeas.svg)](https://forge.puppetlabs.com/camptocamp/augeas) +[![Build Status](https://img.shields.io/travis/camptocamp/puppet-augeas/master.svg)](https://travis-ci.org/camptocamp/puppet-augeas) +[![Gemnasium](https://img.shields.io/gemnasium/camptocamp/puppet-augeas.svg)](https://gemnasium.com/camptocamp/puppet-augeas) +[![By Camptocamp](https://img.shields.io/badge/by-camptocamp-fb7047.svg)](http://www.camptocamp.com) **Install and configure Augeas.** @@ -36,18 +39,22 @@ The `augeas::lens` definition allows you to deploy an Augeas lens and any associ Parameters: - *ensure*: present/absent -- *lens_source*: the source for the lens -- *test_source*: optionally, the source for the test file. +- *lens_content*: the content of the lens +- *lens_source*: deprecated, the source for the lens +- *test_content*: optionally, the content of the test file +- *test_source*: deprecated, the source for the test file. - *stock_since*: optionally, indicate in which version of Augeas the lens became stock, so it will not be deployed above that version. Example usage: - augeas::lens { 'networkmanager': - lens_source => 'puppet:///modules/networkmanager/lenses/networkmanager.aug', - test_source => 'puppet:///modules/networkmanager/lenses/test_networkmanager.aug', - stock_since => '1.0.0', - } +```puppet +augeas::lens { 'networkmanager': + lens_content => file('networkmanager/lenses/networkmanager.aug'), + test_content => file('networkmanager/lenses/test_networkmanager.aug'), + stock_since => '1.0.0', +} +``` ### Functions @@ -4,8 +4,14 @@ require 'puppet-lint/tasks/puppet-lint' Rake::Task[:lint].clear PuppetLint::RakeTask.new :lint do |config| config.ignore_paths = ["spec/**/*.pp", "pkg/**/*.pp", "vendor/**/*.pp"] - config.disable_checks = ['80chars'] + config.disable_checks = ['140chars'] config.fail_on_warnings = true end PuppetSyntax.exclude_paths = ["spec/fixtures/**/*.pp", "vendor/**/*"] + +# Publishing tasks +unless RUBY_VERSION =~ /^1\./ + require 'puppet_blacksmith' + require 'puppet_blacksmith/rake_tasks' +end diff --git a/lib/puppet/parser/functions/augeas.rb b/lib/puppet/parser/functions/augeas.rb index 08026f7..610aa8a 100644 --- a/lib/puppet/parser/functions/augeas.rb +++ b/lib/puppet/parser/functions/augeas.rb @@ -36,7 +36,7 @@ Would result in: aug = Augeas::open(nil, nil, Augeas::NO_MODL_AUTOLOAD) augeas_version = aug.get('/augeas/version') raise(Puppet::ParseError, 'augeas(): requires Augeas 1.0.0 or greater') unless Puppet::Util::Package.versioncmp(augeas_version, '1.0.0') >= 0 - raise(Puppet::ParseError, 'augeas(): requires ruby-augeas 0.5.0 or greater') unless aug.methods.include?('text_store') + raise(Puppet::ParseError, 'augeas(): requires ruby-augeas 0.5.0 or greater') unless aug.methods.include?(:text_store) result = nil begin diff --git a/manifests/init.pp b/manifests/init.pp index 41f4f87..94e50b9 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -4,21 +4,31 @@ # # Parameters: # ['version'] - the desired version of Augeas +# ['ruby_package'] - the desired package name of the Ruby bindings for Augeas # ['ruby_version'] - the desired version of the Ruby bindings for Augeas # ['lens_dir'] - the lens directory to use # ['purge'] - whether to purge lens directories class augeas ( $version = present, + $ruby_package = $::augeas::params::ruby_pkg, $ruby_version = present, - $lens_dir = $augeas::params::lens_dir, + $lens_dir = $::augeas::params::lens_dir, $purge = true, ) inherits augeas::params { - class {'::augeas::packages': } -> - class {'::augeas::files': } -> - Class['augeas'] + if versioncmp($::puppetversion, '4.0.0') >= 0 { + anchor { 'augeas::begin': } + -> class {'::augeas::files': } + -> anchor { 'augeas::end': } + } else { + anchor { 'augeas::begin': } + -> class {'::augeas::packages': } + -> class {'::augeas::files': } + -> anchor { 'augeas::end': } + + # lint:ignore:spaceship_operator_without_tag + Package['ruby-augeas', $augeas::params::augeas_pkgs] -> Augeas <| |> + # lint:endignore + } - # lint:ignore:spaceship_operator_without_tag - Package['ruby-augeas', $augeas::params::augeas_pkgs] -> Augeas <| |> - # lint:endignore } diff --git a/manifests/lens.pp b/manifests/lens.pp index b5b9acd..bda7a0c 100644 --- a/manifests/lens.pp +++ b/manifests/lens.pp @@ -6,7 +6,9 @@ # # Parameters: # ['ensure'] - present/absent +# ['lens_content'] - the content of the lens # ['lens_source'] - the source for the lens +# ['test_content'] - optionally, the content of the test # ['test_source'] - optionally, the source for the test file. # ['stock_since'] - optionally, indicate in which version of Augeas # the lens became stock, so it will not be deployed @@ -15,19 +17,39 @@ # Example usage: # # augeas::lens { 'networkmanager': -# lens_source => 'puppet:///modules/networkmanager/lenses/networkmanager.aug', -# test_source => 'puppet:///modules/networkmanager/lenses/test_networkmanager.aug', -# stock_since => '1.0.0', +# lens_content => file('networkmanager/lenses/networkmanager.aug'), +# test_content => file('networkmanager/lenses/test_networkmanager.aug'), +# stock_since => '1.0.0', # } # define augeas::lens ( - $lens_source, - $ensure=present, - $test_source=false, - $stock_since=false, + $ensure = present, + $lens_content = undef, + $lens_source = undef, + $test_content = undef, + $test_source = undef, + $stock_since = false, ) { - if !defined(Class['augeas']) { - fail('You must declare the augeas class before using augeas::lens') + include ::augeas + + if $lens_source != undef { + if $lens_content != undef { + fail "You can't set both \$lens_source and \$lens_content" + } else { + warning 'Passing "lens_source" is deprecated; please use "lens_content"' + } + } else { + if $lens_content == undef { + fail "You must set either \$lens_source or \$lens_content" + } + } + + if $test_source != undef { + if $test_content != undef { + fail "You can't set both \$test_source and \$test_content" + } else { + warning 'Passing "test_source" is deprecated; please use "test_content"' + } } File { @@ -36,10 +58,6 @@ define augeas::lens ( mode => '0644', } - Exec { - path => $::path, - } - if (!$stock_since or versioncmp($::augeasversion, $stock_since) < 0) { validate_re( @@ -51,26 +69,34 @@ define augeas::lens ( $lens_dest = "${augeas::lens_dir}/${name}.aug" $test_dest = "${augeas::lens_dir}/tests/test_${name}.aug" + # lint:ignore:source_without_rights file { $lens_dest: - ensure => $ensure, - source => $lens_source, + ensure => $ensure, + source => $lens_source, + content => $lens_content, } + # lint:endignore exec { "Typecheck lens ${name}": command => "augparse -I ${augeas::lens_dir} ${lens_dest} || (rm -f ${lens_dest} && exit 1)", + path => "/opt/puppetlabs/puppet/bin:${::path}", refreshonly => true, subscribe => File[$lens_dest], } - if $test_source { + if $test_source or $test_content { + # lint:ignore:source_without_rights file { $test_dest: - ensure => $ensure, - source => $test_source, - notify => Exec["Test lens ${name}"], + ensure => $ensure, + source => $test_source, + content => $test_content, + notify => Exec["Test lens ${name}"], } + # lint:endignore exec { "Test lens ${name}": command => "augparse -I ${augeas::lens_dir} ${test_dest} || (rm -f ${lens_dest} && rm -f ${test_dest} && exit 1)", + path => "/opt/puppetlabs/puppet/bin:${::path}", refreshonly => true, subscribe => File[$lens_dest, $test_dest], } diff --git a/manifests/packages.pp b/manifests/packages.pp index ff8628d..ff0d5c8 100644 --- a/manifests/packages.pp +++ b/manifests/packages.pp @@ -9,6 +9,6 @@ class augeas::packages { package { 'ruby-augeas': ensure => $::augeas::ruby_version, - name => $::augeas::params::ruby_pkg, + name => $::augeas::ruby_package, } } diff --git a/manifests/params.pp b/manifests/params.pp index e540033..bf28630 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -3,28 +3,34 @@ # Default parameters for the Augeas module # class augeas::params { - $lens_dir = '/usr/share/augeas/lenses' case $::osfamily { 'RedHat': { - $ruby_pkg = 'ruby-augeas' + $ruby_pkg = $::operatingsystem ? { + # Amazon Linux AMI (2014.09 and 2015.03) uses ruby 2.0 + 'Amazon' => 'ruby20-augeas', + default => 'ruby-augeas' + } $augeas_pkgs = ['augeas', 'augeas-libs'] } 'Suse': { - # RPM Sources: https://build.opensuse.org/project/show/systemsmanagement:puppet - # SLES 11 SP3 - if versioncmp($::rubyversion, '1.8.7') >= 0 { - $ruby_pkg = 'ruby1.8-rubygem-ruby-augeas' - # SLES 12 - } else { + # RPM Sources: https://build.opensuse.org/project/show/systemsmanagement:puppet + if versioncmp($::rubyversion, '2.1.2') >= 0 { + # SLES 12 / openSUSE $ruby_pkg = 'ruby2.1-rubygem-ruby-augeas' + } else { + # SLES 11 SP3 + $ruby_pkg = 'ruby1.8-rubygem-ruby-augeas' } $augeas_pkgs = ['augeas', 'augeas-lenses', 'libaugeas0' ] } 'Debian': { - if versioncmp($::rubyversion, '1.9.1') >= 0 { + if versioncmp($::rubyversion, '2.1.0') >= 0 { + $ruby_pkg = 'ruby-augeas' + } + elsif versioncmp($::rubyversion, '1.9.1') >= 0 { $ruby_pkg = 'libaugeas-ruby1.9.1' } else { $ruby_pkg = 'libaugeas-ruby1.8' @@ -34,4 +40,14 @@ class augeas::params { default: { fail("Unsupported OS family: ${::osfamily}") } } + + if versioncmp($::puppetversion, '4.0.0') >= 0 { + $lens_dir = '/opt/puppetlabs/puppet/share/augeas/lenses' + } elsif (defined('$is_pe') and str2bool("${::is_pe}")) { # lint:ignore:only_variable_string + # puppet enterpise has a different lens location + $lens_dir = '/opt/puppet/share/augeas/lenses' + } else { + $lens_dir = '/usr/share/augeas/lenses' + } + } diff --git a/metadata.json b/metadata.json index f6bfbf9..a535ed6 100644 --- a/metadata.json +++ b/metadata.json @@ -1,6 +1,6 @@ { "name": "camptocamp-augeas", - "version": "1.1.6", + "version": "1.6.1", "author": "camptocamp", "summary": "Camptocamp Augeas module", "license": "Apache-2.0", @@ -17,11 +17,11 @@ "requirements": [ { "name": "pe", - "version_requirement": "3.x" + "version_requirement": "4.x" }, { "name": "puppet", - "version_requirement": "3.x" + "version_requirement": "4.x" } ], "operatingsystem_support": [ @@ -46,17 +46,13 @@ "5", "6" ] + }, + { + "operatingsystem": "Amazon", + "operatingsystemrelease": [ + "2014.09", + "2015.03" + ] } - ], - "puppet_version": [ - "2.7", - "3.0", - "3.1", - "3.2", - "3.3", - "3.4", - "3.5", - "3.6", - "3.7" ] } diff --git a/spec/acceptance/nodesets/centos-5-x86_64-docker.yml b/spec/acceptance/nodesets/centos-5-x86_64-docker.yml new file mode 100644 index 0000000..679afb0 --- /dev/null +++ b/spec/acceptance/nodesets/centos-5-x86_64-docker.yml @@ -0,0 +1,15 @@ +HOSTS: + centos-5-x64: + default_apply_opts: + order: random + strict_variables: + platform: el-5-x86_64 + hypervisor : docker + image: centos:5 + docker_preserve_image: true + docker_cmd: '["/sbin/init"]' + docker_image_commands: + - 'yum install -y crontabs tar wget' +CONFIG: + type: foss + log_level: debug diff --git a/spec/acceptance/nodesets/centos-5.yml b/spec/acceptance/nodesets/centos-5.yml new file mode 100644 index 0000000..a26f27f --- /dev/null +++ b/spec/acceptance/nodesets/centos-5.yml @@ -0,0 +1,16 @@ +HOSTS: + centos-5-x64: + default_apply_opts: + order: random + strict_variables: + platform: el-5-x86_64 + hypervisor : docker + image: tianon/centos:5.10 + docker_preserve_image: true + docker_cmd: '["/sbin/init"]' + docker_image_commands: + - 'yum install -y crontabs tar wget which' + - 'sed -i -e "/mingetty/d" /etc/inittab' +CONFIG: + type: aio + log_level: debug diff --git a/spec/acceptance/nodesets/centos-6-x86_64-docker.yml b/spec/acceptance/nodesets/centos-6-x86_64-docker.yml new file mode 100644 index 0000000..9cab03d --- /dev/null +++ b/spec/acceptance/nodesets/centos-6-x86_64-docker.yml @@ -0,0 +1,15 @@ +HOSTS: + centos-6-x64: + default_apply_opts: + order: random + strict_variables: + platform: el-6-x86_64 + hypervisor : docker + image: centos:6 + docker_preserve_image: true + docker_cmd: '["/sbin/init"]' + docker_image_commands: + - 'yum install -y crontabs tar wget' +CONFIG: + type: foss + log_level: debug diff --git a/spec/acceptance/nodesets/centos-6-x86_64-openstack.yml b/spec/acceptance/nodesets/centos-6-x86_64-openstack.yml new file mode 100644 index 0000000..e325b9e --- /dev/null +++ b/spec/acceptance/nodesets/centos-6-x86_64-openstack.yml @@ -0,0 +1,14 @@ +HOSTS: + centos-6-x64: + default_apply_opts: + order: random + strict_variables: + platform: el-6-x86_64 + hypervisor : openstack + flavor: m1.small + image: centos-6-latest + user: root +CONFIG: + type: foss + log_level: debug + openstack_network: default diff --git a/spec/acceptance/nodesets/centos-6-x86_64-vagrant.yml b/spec/acceptance/nodesets/centos-6-x86_64-vagrant.yml new file mode 100644 index 0000000..f06036e --- /dev/null +++ b/spec/acceptance/nodesets/centos-6-x86_64-vagrant.yml @@ -0,0 +1,11 @@ +HOSTS: + centos-6-x64: + default_apply_opts: + order: random + strict_variables: + platform: el-6-x86_64 + hypervisor : vagrant + box : camptocamp/centos-6-x86_64 +CONFIG: + type: foss + log_level: debug diff --git a/spec/acceptance/nodesets/centos-6.yml b/spec/acceptance/nodesets/centos-6.yml new file mode 100644 index 0000000..71e23cd --- /dev/null +++ b/spec/acceptance/nodesets/centos-6.yml @@ -0,0 +1,17 @@ +HOSTS: + centos-6-x64: + default_apply_opts: + order: random + strict_variables: + platform: el-6-x86_64 + hypervisor : docker + image: centos:6 + docker_preserve_image: true + docker_cmd: '["/sbin/init"]' + docker_image_commands: + - 'rm -rf /var/run/network/*' + - 'yum install -y crontabs tar wget' + - 'rm /etc/init/tty.conf' +CONFIG: + type: aio + log_level: debug diff --git a/spec/acceptance/nodesets/centos-7-x86_64-docker.yml b/spec/acceptance/nodesets/centos-7-x86_64-docker.yml index 599a681..0bc9727 100644 --- a/spec/acceptance/nodesets/centos-7-x86_64-docker.yml +++ b/spec/acceptance/nodesets/centos-7-x86_64-docker.yml @@ -1,12 +1,15 @@ HOSTS: centos-7-x64: default_apply_opts: + order: random strict_variables: platform: el-7-x86_64 hypervisor : docker image: centos:7 - # This stops the image from being deleted on completion, speeding up the process. docker_preserve_image: true + docker_cmd: '["/usr/sbin/init"]' + docker_image_commands: + - 'yum install -y crontabs tar wget' CONFIG: type: foss log_level: debug diff --git a/spec/acceptance/nodesets/centos-7-x86_64-openstack.yml b/spec/acceptance/nodesets/centos-7-x86_64-openstack.yml index 37dfc5f..9003c86 100644 --- a/spec/acceptance/nodesets/centos-7-x86_64-openstack.yml +++ b/spec/acceptance/nodesets/centos-7-x86_64-openstack.yml @@ -1,11 +1,12 @@ HOSTS: centos-7-x64: default_apply_opts: + order: random strict_variables: platform: el-7-x86_64 hypervisor : openstack flavor: m1.small - image: centos-7-x86_64-genericcloud-20140929_01 + image: centos-7-latest user: centos CONFIG: type: foss diff --git a/spec/acceptance/nodesets/centos-7-x86_64-vagrant.yml b/spec/acceptance/nodesets/centos-7-x86_64-vagrant.yml index fe0f83b..95402e5 100644 --- a/spec/acceptance/nodesets/centos-7-x86_64-vagrant.yml +++ b/spec/acceptance/nodesets/centos-7-x86_64-vagrant.yml @@ -1,10 +1,11 @@ HOSTS: centos-7-x64: default_apply_opts: + order: random strict_variables: platform: el-7-x86_64 hypervisor : vagrant - box : puppetlabs/centos-7.0-64-nocm + box : camptocamp/centos-7-x86_64 CONFIG: type: foss log_level: debug diff --git a/spec/acceptance/nodesets/centos-7.yml b/spec/acceptance/nodesets/centos-7.yml new file mode 100644 index 0000000..a8fa468 --- /dev/null +++ b/spec/acceptance/nodesets/centos-7.yml @@ -0,0 +1,15 @@ +HOSTS: + centos-7-x64: + default_apply_opts: + order: random + strict_variables: + platform: el-7-x86_64 + hypervisor : docker + image: centos:7 + docker_preserve_image: true + docker_cmd: '["/usr/sbin/init"]' + docker_image_commands: + - 'yum install -y crontabs tar wget iproute' +CONFIG: + type: aio + log_level: debug diff --git a/spec/acceptance/nodesets/debian-6-x86_64-docker.yml b/spec/acceptance/nodesets/debian-6-x86_64-docker.yml index 0296d12..359dae7 100644 --- a/spec/acceptance/nodesets/debian-6-x86_64-docker.yml +++ b/spec/acceptance/nodesets/debian-6-x86_64-docker.yml @@ -1,12 +1,15 @@ HOSTS: debian-6-x64: default_apply_opts: + order: random strict_variables: platform: debian-6-amd64 hypervisor : docker image: debian:6 - # This stops the image from being deleted on completion, speeding up the process. docker_preserve_image: true + docker_cmd: '["/sbin/init"]' + docker_image_commands: + - 'apt-get install -y wget' CONFIG: type: foss log_level: debug diff --git a/spec/acceptance/nodesets/debian-6-x86_64-openstack.yml b/spec/acceptance/nodesets/debian-6-x86_64-openstack.yml new file mode 100644 index 0000000..c6c192f --- /dev/null +++ b/spec/acceptance/nodesets/debian-6-x86_64-openstack.yml @@ -0,0 +1,14 @@ +HOSTS: + debian-6-x64: + default_apply_opts: + order: random + strict_variables: + platform: debian-6-amd64 + hypervisor : openstack + flavor: m1.small + image: debian-6-latest + user: debian +CONFIG: + type: foss + log_level: debug + openstack_network: default diff --git a/spec/acceptance/nodesets/debian-6-x86_64-vagrant.yml b/spec/acceptance/nodesets/debian-6-x86_64-vagrant.yml index 23dae1b..03db0fa 100644 --- a/spec/acceptance/nodesets/debian-6-x86_64-vagrant.yml +++ b/spec/acceptance/nodesets/debian-6-x86_64-vagrant.yml @@ -1,6 +1,7 @@ HOSTS: debian-6-x64: default_apply_opts: + order: random strict_variables: platform: debian-6-amd64 hypervisor : vagrant diff --git a/spec/acceptance/nodesets/debian-6.yml b/spec/acceptance/nodesets/debian-6.yml new file mode 100644 index 0000000..d7b0275 --- /dev/null +++ b/spec/acceptance/nodesets/debian-6.yml @@ -0,0 +1,15 @@ +HOSTS: + debian-6-x64: + default_apply_opts: + order: random + strict_variables: + platform: debian-6-amd64 + hypervisor : docker + image: debian/eol:squeeze + docker_preserve_image: true + docker_cmd: '["/sbin/init"]' + docker_image_commands: + - 'apt-get install -y cron locales-all net-tools wget' +CONFIG: + type: aio + log_level: debug diff --git a/spec/acceptance/nodesets/debian-7-x86_64-docker.yml b/spec/acceptance/nodesets/debian-7-x86_64-docker.yml index ef1c9b2..fc11f57 100644 --- a/spec/acceptance/nodesets/debian-7-x86_64-docker.yml +++ b/spec/acceptance/nodesets/debian-7-x86_64-docker.yml @@ -1,12 +1,15 @@ HOSTS: debian-7-x64: default_apply_opts: + order: random strict_variables: platform: debian-7-amd64 hypervisor : docker image: debian:7 - # This stops the image from being deleted on completion, speeding up the process. docker_preserve_image: true + docker_cmd: '["/sbin/init"]' + docker_image_commands: + - 'apt-get install -y cron wget' CONFIG: type: foss log_level: debug diff --git a/spec/acceptance/nodesets/debian-7-x86_64-openstack.yml b/spec/acceptance/nodesets/debian-7-x86_64-openstack.yml index e52336b..017b4c7 100644 --- a/spec/acceptance/nodesets/debian-7-x86_64-openstack.yml +++ b/spec/acceptance/nodesets/debian-7-x86_64-openstack.yml @@ -1,11 +1,12 @@ HOSTS: debian-7-x64: default_apply_opts: + order: random strict_variables: platform: debian-7-amd64 hypervisor : openstack flavor: m1.small - image: debian-7-amd64-20141121 + image: debian-7-latest user: debian CONFIG: type: foss diff --git a/spec/acceptance/nodesets/debian-7-x86_64-vagrant.yml b/spec/acceptance/nodesets/debian-7-x86_64-vagrant.yml index 86c2165..8ed1264 100644 --- a/spec/acceptance/nodesets/debian-7-x86_64-vagrant.yml +++ b/spec/acceptance/nodesets/debian-7-x86_64-vagrant.yml @@ -1,10 +1,11 @@ HOSTS: debian-7-x64: default_apply_opts: + order: random strict_variables: platform: debian-7-amd64 hypervisor : vagrant - box : puppetlabs/debian-7.8-64-nocm + box : camptocamp/debian-7-amd64 CONFIG: type: foss log_level: debug diff --git a/spec/acceptance/nodesets/debian-7.yml b/spec/acceptance/nodesets/debian-7.yml new file mode 100644 index 0000000..9591ea7 --- /dev/null +++ b/spec/acceptance/nodesets/debian-7.yml @@ -0,0 +1,15 @@ +HOSTS: + debian-7-x64: + default_apply_opts: + order: random + strict_variables: + platform: debian-7-amd64 + hypervisor : docker + image: debian:7 + docker_preserve_image: true + docker_cmd: '["/sbin/init"]' + docker_image_commands: + - 'apt-get install -y cron locales-all net-tools wget' +CONFIG: + type: aio + log_level: debug diff --git a/spec/acceptance/nodesets/debian-8-x86_64-docker.yml b/spec/acceptance/nodesets/debian-8-x86_64-docker.yml index 28c3e02..86a55e1 100644 --- a/spec/acceptance/nodesets/debian-8-x86_64-docker.yml +++ b/spec/acceptance/nodesets/debian-8-x86_64-docker.yml @@ -1,12 +1,15 @@ HOSTS: debian-8-x64: default_apply_opts: + order: random strict_variables: platform: debian-8-amd64 hypervisor : docker image: debian:8 - # This stops the image from being deleted on completion, speeding up the process. docker_preserve_image: true + docker_cmd: '["/sbin/init"]' + docker_image_commands: + - 'apt-get install -y cron wget' CONFIG: type: foss log_level: debug diff --git a/spec/acceptance/nodesets/debian-8-x86_64-openstack.yml b/spec/acceptance/nodesets/debian-8-x86_64-openstack.yml index 194ca46..003b6f4 100644 --- a/spec/acceptance/nodesets/debian-8-x86_64-openstack.yml +++ b/spec/acceptance/nodesets/debian-8-x86_64-openstack.yml @@ -1,13 +1,14 @@ HOSTS: debian-8-x64: default_apply_opts: + order: random strict_variables: platform: debian-8-amd64 hypervisor : openstack flavor: m1.small - image: debian-8-amd64-20141121 + image: debian-8-latest user: debian CONFIG: type: foss - openstack_network: default log_level: debug + openstack_network: default diff --git a/spec/acceptance/nodesets/debian-8-x86_64-vagrant.yml b/spec/acceptance/nodesets/debian-8-x86_64-vagrant.yml new file mode 100644 index 0000000..5cc7f0c --- /dev/null +++ b/spec/acceptance/nodesets/debian-8-x86_64-vagrant.yml @@ -0,0 +1,11 @@ +HOSTS: + debian-8-x64: + default_apply_opts: + order: random + strict_variables: + platform: debian-8-amd64 + hypervisor : vagrant + box : camptocamp/debian-8-amd64 +CONFIG: + type: foss + log_level: debug diff --git a/spec/acceptance/nodesets/debian-8.yml b/spec/acceptance/nodesets/debian-8.yml new file mode 100644 index 0000000..5fb24c6 --- /dev/null +++ b/spec/acceptance/nodesets/debian-8.yml @@ -0,0 +1,16 @@ +HOSTS: + debian-8-x64: + default_apply_opts: + order: random + strict_variables: + platform: debian-8-amd64 + hypervisor : docker + image: debian:8 + docker_preserve_image: true + docker_cmd: '["/sbin/init"]' + docker_image_commands: + - 'apt-get install -y cron locales-all net-tools wget' + - 'rm -f /usr/sbin/policy-rc.d' +CONFIG: + type: aio + log_level: debug diff --git a/spec/acceptance/nodesets/ubuntu-10.04-x86_64-docker.yml b/spec/acceptance/nodesets/ubuntu-10.04-x86_64-docker.yml new file mode 100644 index 0000000..933dee6 --- /dev/null +++ b/spec/acceptance/nodesets/ubuntu-10.04-x86_64-docker.yml @@ -0,0 +1,13 @@ +HOSTS: + ubuntu-1004-x64: + default_apply_opts: + order: random + strict_variables: + platform: ubuntu-10.04-amd64 + hypervisor : docker + image: ubuntu:10.04 + # This stops the image from being deleted on completion, speeding up the process. + docker_preserve_image: true +CONFIG: + type: foss + log_level: debug diff --git a/spec/acceptance/nodesets/ubuntu-12.04-x86_64-docker.yml b/spec/acceptance/nodesets/ubuntu-12.04-x86_64-docker.yml new file mode 100644 index 0000000..f0ec72b --- /dev/null +++ b/spec/acceptance/nodesets/ubuntu-12.04-x86_64-docker.yml @@ -0,0 +1,15 @@ +HOSTS: + ubuntu-1204-x64: + default_apply_opts: + order: random + strict_variables: + platform: ubuntu-12.04-amd64 + hypervisor : docker + image: ubuntu:12.04 + docker_preserve_image: true + docker_cmd: '["/sbin/init"]' + docker_image_commands: + - 'apt-get install -y wget' +CONFIG: + type: foss + log_level: debug diff --git a/spec/acceptance/nodesets/ubuntu-12.04-x86_64-openstack.yml b/spec/acceptance/nodesets/ubuntu-12.04-x86_64-openstack.yml new file mode 100644 index 0000000..f81b04b --- /dev/null +++ b/spec/acceptance/nodesets/ubuntu-12.04-x86_64-openstack.yml @@ -0,0 +1,14 @@ +HOSTS: + ubuntu-1204-x64: + default_apply_opts: + order: random + strict_variables: + platform: ubuntu-12.04-amd64 + hypervisor : openstack + flavor: m1.small + image: ubuntu-1204-latest + user: ubuntu +CONFIG: + type: foss + log_level: debug + openstack_network: default diff --git a/spec/acceptance/nodesets/ubuntu-12.04.yml b/spec/acceptance/nodesets/ubuntu-12.04.yml new file mode 100644 index 0000000..594e177 --- /dev/null +++ b/spec/acceptance/nodesets/ubuntu-12.04.yml @@ -0,0 +1,16 @@ +HOSTS: + ubuntu-1204-x64: + default_apply_opts: + order: random + strict_variables: + platform: ubuntu-12.04-amd64 + hypervisor : docker + image: ubuntu:12.04 + docker_preserve_image: true + docker_cmd: '["/sbin/init"]' + docker_image_commands: + - 'apt-get install -y net-tools wget' + - 'locale-gen en_US.UTF-8' +CONFIG: + type: aio + log_level: debug diff --git a/spec/acceptance/nodesets/ubuntu-14.04-x86_64-docker.yml b/spec/acceptance/nodesets/ubuntu-14.04-x86_64-docker.yml new file mode 100644 index 0000000..6fb9281 --- /dev/null +++ b/spec/acceptance/nodesets/ubuntu-14.04-x86_64-docker.yml @@ -0,0 +1,15 @@ +HOSTS: + ubuntu-1404-x64: + default_apply_opts: + order: random + strict_variables: + platform: ubuntu-14.04-amd64 + hypervisor : docker + image: ubuntu:14.04 + docker_preserve_image: true + docker_cmd: '["/sbin/init"]' + docker_image_commands: + - 'apt-get install -y wget' +CONFIG: + type: foss + log_level: debug diff --git a/spec/acceptance/nodesets/ubuntu-14.04-x86_64-openstack.yml b/spec/acceptance/nodesets/ubuntu-14.04-x86_64-openstack.yml new file mode 100644 index 0000000..2eeb912 --- /dev/null +++ b/spec/acceptance/nodesets/ubuntu-14.04-x86_64-openstack.yml @@ -0,0 +1,14 @@ +HOSTS: + ubuntu-1404-x64: + default_apply_opts: + order: random + strict_variables: + platform: ubuntu-14.04-amd64 + hypervisor : openstack + flavor: m1.small + image: ubuntu-1404-latest + user: ubuntu +CONFIG: + type: foss + log_level: debug + openstack_network: default diff --git a/spec/acceptance/nodesets/ubuntu-14.04-x86_64-vagrant.yml b/spec/acceptance/nodesets/ubuntu-14.04-x86_64-vagrant.yml index a3edb70..3b37695 100644 --- a/spec/acceptance/nodesets/ubuntu-14.04-x86_64-vagrant.yml +++ b/spec/acceptance/nodesets/ubuntu-14.04-x86_64-vagrant.yml @@ -1,6 +1,7 @@ HOSTS: - ubuntu-14.04-x64: + ubuntu-1404-x64: default_apply_opts: + order: random strict_variables: platform: ubuntu-14.04-amd64 hypervisor : vagrant diff --git a/spec/acceptance/nodesets/ubuntu-14.04.yml b/spec/acceptance/nodesets/ubuntu-14.04.yml new file mode 100644 index 0000000..2b293c9 --- /dev/null +++ b/spec/acceptance/nodesets/ubuntu-14.04.yml @@ -0,0 +1,18 @@ +HOSTS: + ubuntu-1404-x64: + default_apply_opts: + order: random + strict_variables: + platform: ubuntu-14.04-amd64 + hypervisor : docker + image: ubuntu:14.04 + docker_preserve_image: true + docker_cmd: '["/sbin/init"]' + docker_image_commands: + - 'rm /usr/sbin/policy-rc.d' + - 'rm /sbin/initctl; dpkg-divert --rename --remove /sbin/initctl' + - 'apt-get install -y net-tools wget' + - 'locale-gen en_US.UTF-8' +CONFIG: + type: aio + log_level: debug diff --git a/spec/acceptance/nodesets/ubuntu-14.10-x86_64-docker.yml b/spec/acceptance/nodesets/ubuntu-14.10-x86_64-docker.yml new file mode 100644 index 0000000..2be425c --- /dev/null +++ b/spec/acceptance/nodesets/ubuntu-14.10-x86_64-docker.yml @@ -0,0 +1,15 @@ +HOSTS: + ubuntu-1410-x64: + default_apply_opts: + order: random + strict_variables: + platform: ubuntu-14.10-amd64 + hypervisor : docker + image: ubuntu:14.10 + docker_preserve_image: true + docker_cmd: '["/sbin/init"]' + docker_image_commands: + - 'apt-get install -y wget' +CONFIG: + type: foss + log_level: debug diff --git a/spec/acceptance/nodesets/ubuntu-14.10-x86_64-openstack.yml b/spec/acceptance/nodesets/ubuntu-14.10-x86_64-openstack.yml new file mode 100644 index 0000000..58a2acd --- /dev/null +++ b/spec/acceptance/nodesets/ubuntu-14.10-x86_64-openstack.yml @@ -0,0 +1,14 @@ +HOSTS: + ubuntu-1410-x64: + default_apply_opts: + order: random + strict_variables: + platform: ubuntu-14.10-amd64 + hypervisor : openstack + flavor: m1.small + image: ubuntu-1410-latest + user: ubuntu +CONFIG: + type: foss + log_level: debug + openstack_network: default diff --git a/spec/acceptance/nodesets/ubuntu-14.10.yml b/spec/acceptance/nodesets/ubuntu-14.10.yml new file mode 100644 index 0000000..7ce09b2 --- /dev/null +++ b/spec/acceptance/nodesets/ubuntu-14.10.yml @@ -0,0 +1,18 @@ +HOSTS: + ubuntu-1410-x64: + default_apply_opts: + order: random + strict_variables: + platform: ubuntu-14.10-amd64 + hypervisor : docker + image: ubuntu:14.10 + docker_preserve_image: true + docker_cmd: '["/sbin/init"]' + docker_image_commands: + - 'rm /usr/sbin/policy-rc.d' + - 'rm /sbin/initctl; dpkg-divert --rename --remove /sbin/initctl' + - 'apt-get install -y net-tools wget' + - 'locale-gen en_US.UTF-8' +CONFIG: + type: aio + log_level: debug diff --git a/spec/acceptance/nodesets/ubuntu-15.04-x86_64-docker.yml b/spec/acceptance/nodesets/ubuntu-15.04-x86_64-docker.yml new file mode 100644 index 0000000..caed722 --- /dev/null +++ b/spec/acceptance/nodesets/ubuntu-15.04-x86_64-docker.yml @@ -0,0 +1,15 @@ +HOSTS: + ubuntu-1504-x64: + default_apply_opts: + order: random + strict_variables: + platform: ubuntu-15.04-amd64 + hypervisor : docker + image: ubuntu:15.04 + docker_preserve_image: true + docker_cmd: '["/sbin/init"]' + docker_image_commands: + - 'apt-get install -y wget' +CONFIG: + type: foss + log_level: debug diff --git a/spec/acceptance/nodesets/ubuntu-15.04-x86_64-openstack.yml b/spec/acceptance/nodesets/ubuntu-15.04-x86_64-openstack.yml new file mode 100644 index 0000000..22ef76c --- /dev/null +++ b/spec/acceptance/nodesets/ubuntu-15.04-x86_64-openstack.yml @@ -0,0 +1,14 @@ +HOSTS: + ubuntu-1504-x64: + default_apply_opts: + order: random + strict_variables: + platform: ubuntu-15.04-amd64 + hypervisor : openstack + flavor: m1.small + image: ubuntu-1504-latest + user: ubuntu +CONFIG: + type: foss + log_level: debug + openstack_network: default diff --git a/spec/acceptance/nodesets/ubuntu-15.04.yml b/spec/acceptance/nodesets/ubuntu-15.04.yml new file mode 100644 index 0000000..329f331 --- /dev/null +++ b/spec/acceptance/nodesets/ubuntu-15.04.yml @@ -0,0 +1,16 @@ +HOSTS: + ubuntu-1504-x64: + default_apply_opts: + order: random + strict_variables: + platform: ubuntu-15.04-amd64 + hypervisor : docker + image: ubuntu:15.04 + docker_preserve_image: true + docker_cmd: '["/sbin/init"]' + docker_image_commands: + - 'apt-get install -y net-tools wget' + - 'locale-gen en_US.UTF-8' +CONFIG: + type: aio + log_level: debug diff --git a/spec/acceptance/nodesets/ubuntu-15.10.yml b/spec/acceptance/nodesets/ubuntu-15.10.yml new file mode 100644 index 0000000..487795a --- /dev/null +++ b/spec/acceptance/nodesets/ubuntu-15.10.yml @@ -0,0 +1,16 @@ +HOSTS: + ubuntu-1510-x64: + default_apply_opts: + order: random + strict_variables: + platform: ubuntu-15.10-amd64 + hypervisor : docker + image: ubuntu:15.10 + docker_preserve_image: true + docker_cmd: '["/sbin/init"]' + docker_image_commands: + - 'apt-get install -y net-tools wget' + - 'locale-gen en_US.UTF-8' +CONFIG: + type: aio + log_level: debug diff --git a/spec/acceptance/nodesets/ubuntu-16.04.yml b/spec/acceptance/nodesets/ubuntu-16.04.yml new file mode 100644 index 0000000..6c32b96 --- /dev/null +++ b/spec/acceptance/nodesets/ubuntu-16.04.yml @@ -0,0 +1,16 @@ +HOSTS: + ubuntu-1604-x64: + default_apply_opts: + order: random + strict_variables: + platform: ubuntu-16.04-amd64 + hypervisor : docker + image: ubuntu:16.04 + docker_preserve_image: true + docker_cmd: '["/sbin/init"]' + docker_image_commands: + - 'apt-get install -y net-tools wget' + - 'locale-gen en_US.UTF-8' +CONFIG: + type: aio + log_level: debug diff --git a/spec/classes/augeas_spec.rb b/spec/classes/augeas_spec.rb index ab4241f..16f76f4 100644 --- a/spec/classes/augeas_spec.rb +++ b/spec/classes/augeas_spec.rb @@ -10,10 +10,12 @@ describe 'augeas' do end it 'should fail' do - expect { is_expected.to contain_package('ruby-augeas') }.to raise_error(Puppet::Error, /Unsupported OS family/) + expect { is_expected.to compile }.to raise_error(/Unsupported OS family/) end end + lens_dir = Puppet.version < '4.0.0' ? '/usr/share/augeas/lenses' : '/opt/puppetlabs/puppet/share/augeas/lenses' + on_supported_os.each do |os, facts| context "on #{os}" do let(:facts) do @@ -21,53 +23,65 @@ describe 'augeas' do end context 'without params' do - case facts[:osfamily] - when 'Debian' - it { is_expected.to contain_package('libaugeas0').with( - :ensure => 'present' - ) } - it { is_expected.to contain_package('augeas-tools').with( - :ensure => 'present' - ) } - it { is_expected.to contain_package('augeas-lenses').with( - :ensure => 'present' - ) } - case facts[:lsbdistcodename] - when 'squeeze', 'lucid', 'precise' - it { is_expected.to contain_package('ruby-augeas').with( - :ensure => 'present', - :name => 'libaugeas-ruby1.8' + if Puppet.version < '4.0.0' + case facts[:osfamily] + when 'Debian' + it { is_expected.to contain_package('libaugeas0').with( + :ensure => 'present' + ) } + it { is_expected.to contain_package('augeas-tools').with( + :ensure => 'present' + ) } + it { is_expected.to contain_package('augeas-lenses').with( + :ensure => 'present' + ) } + case facts[:lsbdistcodename] + when 'squeeze', 'lucid', 'precise' + let(:facts) do + super().merge({ + :rubyversion => '1.8.7', + }) + end + it { is_expected.to contain_package('ruby-augeas').with( + :ensure => 'present', + :name => 'libaugeas-ruby1.8' + ) } + else + let(:facts) do + super().merge({ + :rubyversion => '1.9.3', + }) + end + it { is_expected.to contain_package('ruby-augeas').with( + :ensure => 'present', + :name => 'libaugeas-ruby1.9.1' + ) } + end + when 'RedHat' + it { is_expected.to contain_package('augeas').with( + :ensure => 'present' + ) } + it { is_expected.to contain_package('augeas-libs').with( + :ensure => 'present' ) } - else it { is_expected.to contain_package('ruby-augeas').with( :ensure => 'present', - :name => 'libaugeas-ruby1.9.1' + :name => 'ruby-augeas' ) } end - when 'RedHat' - it { is_expected.to contain_package('augeas').with( - :ensure => 'present' - ) } - it { is_expected.to contain_package('augeas-libs').with( - :ensure => 'present' - ) } - it { is_expected.to contain_package('ruby-augeas').with( - :ensure => 'present', - :name => 'ruby-augeas' - ) } end - it { is_expected.to contain_file('/usr/share/augeas/lenses').with( + it { is_expected.to contain_file(lens_dir).with( :ensure => 'directory', :purge => 'true', :force => 'true', :recurse => 'true', :recurselimit => 1 ) } - it { is_expected.to contain_file('/usr/share/augeas/lenses/dist').with( + it { is_expected.to contain_file("#{lens_dir}/dist").with( :ensure => 'directory', :purge => 'false' ) } - it { is_expected.to contain_file('/usr/share/augeas/lenses/tests').with( + it { is_expected.to contain_file("#{lens_dir}/tests").with( :ensure => 'directory', :purge => 'true', :force => 'true' @@ -82,42 +96,53 @@ describe 'augeas' do } end - case facts[:osfamily] - when 'Debian' - it { is_expected.to contain_package('libaugeas0').with( - :ensure => '1.2.3' - ) } - it { is_expected.to contain_package('augeas-tools').with( - :ensure => '1.2.3' - ) } - it { is_expected.to contain_package('augeas-lenses').with( - :ensure => '1.2.3' - ) } - case facts[:lsbdistcodename] - when 'squeeze', 'lucid', 'precise' - it { is_expected.to contain_package('ruby-augeas').with( - :ensure => '3.2.1', - :name => 'libaugeas-ruby1.8' + if Puppet.version < '4.0.0' + case facts[:osfamily] + when 'Debian' + it { is_expected.to contain_package('libaugeas0').with( + :ensure => '1.2.3' + ) } + it { is_expected.to contain_package('augeas-tools').with( + :ensure => '1.2.3' + ) } + it { is_expected.to contain_package('augeas-lenses').with( + :ensure => '1.2.3' + ) } + case facts[:lsbdistcodename] + when 'squeeze', 'lucid', 'precise' + let(:facts) do + super().merge({ + :rubyversion => '1.8.7', + }) + end + it { is_expected.to contain_package('ruby-augeas').with( + :ensure => '3.2.1', + :name => 'libaugeas-ruby1.8' + ) } + else + let(:facts) do + super().merge({ + :rubyversion => '1.9.3', + }) + end + it { is_expected.to contain_package('ruby-augeas').with( + :ensure => '3.2.1', + :name => 'libaugeas-ruby1.9.1' + ) } + end + when 'RedHat' + it { is_expected.to contain_package('augeas').with( + :ensure => '1.2.3' + ) } + it { is_expected.to contain_package('augeas-libs').with( + :ensure => '1.2.3' ) } - else it { is_expected.to contain_package('ruby-augeas').with( :ensure => '3.2.1', - :name => 'libaugeas-ruby1.9.1' + :name => 'ruby-augeas' ) } end - when 'RedHat' - it { is_expected.to contain_package('augeas').with( - :ensure => '1.2.3' - ) } - it { is_expected.to contain_package('augeas-libs').with( - :ensure => '1.2.3' - ) } - it { is_expected.to contain_package('ruby-augeas').with( - :ensure => '3.2.1', - :name => 'ruby-augeas' - ) } end - end context 'with a non standard lens_dir' do @@ -144,6 +169,38 @@ describe 'augeas' do :force => 'true' ).without(:recurse) } end + + context 'with Puppet Enterprise' do + let (:facts) do + facts.merge({ + :is_pe => true, + }) + end + + if Puppet::Util::Package.versioncmp(Puppet.version, '4.0.0') >= 0 + # the enterprise lens dir is the same in 4 + pe_lens_dir = lens_dir + else + pe_lens_dir = '/opt/puppet/share/augeas/lenses' + end + + it { is_expected.to contain_file(pe_lens_dir).with( + :ensure => 'directory', + :force => 'true', + :recurse => 'true', + :recurselimit => 1 + ) } + it { is_expected.to contain_file("#{pe_lens_dir}/dist").with( + :ensure => 'directory', + :purge => 'false' + ) } + it { is_expected.to contain_file("#{pe_lens_dir}/tests").with( + :ensure => 'directory', + :force => 'true', + :purge => 'true' + ).without(:recurse) } + end + end end end diff --git a/spec/defines/augeas_lens_spec.rb b/spec/defines/augeas_lens_spec.rb index 7feeefb..0fa1358 100644 --- a/spec/defines/augeas_lens_spec.rb +++ b/spec/defines/augeas_lens_spec.rb @@ -3,41 +3,20 @@ require 'spec_helper' describe 'augeas::lens' do let (:title) { 'foo' } - context 'when not declaring augeas class first' do - let (:params) do - { - :lens_source => '/tmp/foo.aug', - } - end - - it 'should error' do - expect { - is_expected.to contain_file('/usr/share/augeas/lenses/foo.aug') - }.to raise_error(Puppet::Error, /You must declare the augeas class/) - end - end + lens_dir = Puppet.version < '4.0.0' ? '/usr/share/augeas/lenses' : '/opt/puppetlabs/puppet/share/augeas/lenses' context 'when declaring augeas class first' do - on_supported_os.each do |os, facts| context "on #{os}" do let(:facts) do - facts.merge({ - :augeasversion => :undef, - }) + facts end context 'With standard augeas version' do - let(:pre_condition) do - "class { '::augeas': }" - end - context 'when no lens_source is passed' do it 'should error' do - expect { - is_expected.to contain_file('/usr/share/augeas/lenses/foo.aug') - }.to raise_error(Puppet::Error, /Must pass lens_source/) + expect { is_expected.to compile }.to raise_error(/You must set either \$lens_source or \$lens_content/) end end @@ -48,9 +27,9 @@ describe 'augeas::lens' do } end - it { is_expected.to contain_file('/usr/share/augeas/lenses/foo.aug') } + it { is_expected.to contain_file("#{lens_dir}/foo.aug") } it { is_expected.to contain_exec('Typecheck lens foo') } - it { is_expected.not_to contain_file('/usr/share/augeas/lenses/tests/test_foo.aug') } + it { is_expected.not_to contain_file("#{lens_dir}/tests/test_foo.aug") } it { is_expected.not_to contain_exec('Test lens foo') } end @@ -62,9 +41,9 @@ describe 'augeas::lens' do } end - it { is_expected.to contain_file('/usr/share/augeas/lenses/foo.aug') } + it { is_expected.to contain_file("#{lens_dir}/foo.aug") } + it { is_expected.to contain_file("#{lens_dir}/tests/test_foo.aug") } it { is_expected.to contain_exec('Typecheck lens foo') } - it { is_expected.to contain_file('/usr/share/augeas/lenses/tests/test_foo.aug') } it { is_expected.to contain_exec('Test lens foo') } end end @@ -77,11 +56,13 @@ describe 'augeas::lens' do } end - let(:pre_condition) do - "class { '::augeas': version => '1.0.0' }" + let(:facts) do + super().merge({ + :augeasversion => '1.0.0', + }) end - it { is_expected.to contain_file('/usr/share/augeas/lenses/foo.aug') } + it { is_expected.to contain_file("#{lens_dir}/foo.aug") } it { is_expected.to contain_exec('Typecheck lens foo') } end @@ -93,16 +74,16 @@ describe 'augeas::lens' do } end - let(:pre_condition) do - "class { '::augeas': version => '1.3.0' }" + let(:facts) do + super().merge({ + :augeasversion => '1.3.0', + }) end it do - pending "undefined method `negative_failure_message'" - is_expected.not_to contain_file('/usr/share/augeas/lenses/foo.aug') + is_expected.not_to contain_file("#{lens_dir}/foo.aug") end it do - pending "undefined method `negative_failure_message'" is_expected.not_to contain_exec('Typecheck lens foo') end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 86cc740..94d30d5 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -11,7 +11,7 @@ RSpec.configure do |c| @old_env = {} ENV.each_key {|k| @old_env[k] = ENV[k]} - Puppet.settings[:strict_variables]=true if Gem::Version.new(Puppet::PUPPETVERSION) >= Gem::Version.new('3.5') + c.strict_variables = Gem::Version.new(Puppet.version) >= Gem::Version.new('3.5') Puppet.features.stubs(:root?).returns(true) end @@ -35,7 +35,7 @@ Puppet[:modulepath] = File.join(dir, 'fixtures', 'modules') # 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 +if Gem::Requirement.new("~> 2.7.20") =~ ver || Gem::Requirement.new("~> 3.0.0") =~ ver || Gem::Requirement.new("~> 3.5") =~ ver || Gem::Requirement.new("~> 4.0") 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]}/augeasproviders_core/lib" |