diff options
-rw-r--r-- | CHANGELOG.md | 12 | ||||
-rw-r--r-- | Gemfile | 10 | ||||
-rw-r--r-- | Rakefile | 12 | ||||
-rw-r--r-- | manifests/init.pp | 20 | ||||
-rw-r--r-- | manifests/lens.pp | 6 | ||||
-rw-r--r-- | manifests/params.pp | 19 | ||||
-rw-r--r-- | metadata.json | 2 | ||||
-rw-r--r-- | spec/classes/augeas_spec.rb | 138 | ||||
-rw-r--r-- | spec/defines/augeas_lens_spec.rb | 23 | ||||
-rw-r--r-- | spec/spec_helper.rb | 2 |
10 files changed, 145 insertions, 99 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index c0ed6b2..ad77af8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,15 @@ +## 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 @@ -19,13 +19,17 @@ group :development, :unit_tests do gem 'puppet-lint-version_comparison-check', :require => false gem 'puppet-lint-fileserver-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 'github_changelog_generator', :require => false, :git => 'https://github.com/raphink/github-changelog-generator.git', :branch => 'dev/all_patches' if RUBY_VERSION !~ /^1.8/ + gem 'puppet-blacksmith', :require => false if RUBY_VERSION !~ /^1.8/ 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', :require => false + gem 'beaker_spec_helper', :require => false + gem 'serverspec', :require => false end if facterversion = ENV['FACTER_GEM_VERSION'] @@ -9,3 +9,15 @@ PuppetLint::RakeTask.new :lint do |config| end PuppetSyntax.exclude_paths = ["spec/fixtures/**/*.pp", "vendor/**/*"] + +# Publishing tasks +unless RUBY_VERSION =~ /^1\.8/ + require 'puppet_blacksmith' + require 'puppet_blacksmith/rake_tasks' + require 'github_changelog_generator/task' + GitHubChangelogGenerator::RakeTask.new :changelog do |config| + m = Blacksmith::Modulefile.new + config.future_release = m.version + config.release_url = "https://forge.puppetlabs.com/#{m.author}/#{m.name}/%s" + end +end diff --git a/manifests/init.pp b/manifests/init.pp index 094dda1..1257894 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -16,11 +16,19 @@ class augeas ( $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 c7dd6b2..e2c34de 100644 --- a/manifests/lens.pp +++ b/manifests/lens.pp @@ -60,10 +60,6 @@ define augeas::lens ( mode => '0644', } - Exec { - path => $::path, - } - if (!$stock_since or versioncmp($::augeasversion, $stock_since) < 0) { validate_re( @@ -85,6 +81,7 @@ define augeas::lens ( exec { "Typecheck lens ${name}": command => "augparse -I ${augeas::lens_dir} ${lens_dest} || (rm -f ${lens_dest} && exit 1)", + path => $::path, refreshonly => true, subscribe => File[$lens_dest], } @@ -101,6 +98,7 @@ define augeas::lens ( exec { "Test lens ${name}": command => "augparse -I ${augeas::lens_dir} ${test_dest} || (rm -f ${lens_dest} && rm -f ${test_dest} && exit 1)", + path => $::path, refreshonly => true, subscribe => File[$lens_dest, $test_dest], } diff --git a/manifests/params.pp b/manifests/params.pp index e540033..4ca216d 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -3,7 +3,12 @@ # Default parameters for the Augeas module # class augeas::params { - $lens_dir = '/usr/share/augeas/lenses' + + if versioncmp($::puppetversion, '4.0.0') >= 0 { + $lens_dir = '/opt/puppetlabs/puppet/share/augeas/lenses' + } else { + $lens_dir = '/usr/share/augeas/lenses' + } case $::osfamily { 'RedHat': { @@ -12,13 +17,13 @@ class augeas::params { } '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' ] } diff --git a/metadata.json b/metadata.json index 375a8d7..3dc6212 100644 --- a/metadata.json +++ b/metadata.json @@ -1,6 +1,6 @@ { "name": "camptocamp-augeas", - "version": "1.2.10", + "version": "1.2.13", "author": "camptocamp", "summary": "Camptocamp Augeas module", "license": "Apache-2.0", diff --git a/spec/classes/augeas_spec.rb b/spec/classes/augeas_spec.rb index ab4241f..32a390d 100644 --- a/spec/classes/augeas_spec.rb +++ b/spec/classes/augeas_spec.rb @@ -5,69 +5,76 @@ describe 'augeas' do context 'when on an unsupported Operating System' do let (:facts) do { - :osfamily => 'MS-DOS', + :osfamily => 'MS-DOS', + :puppetversion => Puppet.version, } 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 - facts + facts.merge({ + :puppetversion => Puppet.version, + }) 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' + it { is_expected.to contain_package('ruby-augeas').with( + :ensure => 'present', + :name => 'libaugeas-ruby1.8' + ) } + else + 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 +89,43 @@ 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' + it { is_expected.to contain_package('ruby-augeas').with( + :ensure => '3.2.1', + :name => 'libaugeas-ruby1.8' + ) } + else + 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 diff --git a/spec/defines/augeas_lens_spec.rb b/spec/defines/augeas_lens_spec.rb index 21dfd55..f4e5be7 100644 --- a/spec/defines/augeas_lens_spec.rb +++ b/spec/defines/augeas_lens_spec.rb @@ -11,12 +11,12 @@ describe 'augeas::lens' do 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/) + expect { is_expected.to compile }.to raise_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| @@ -24,6 +24,7 @@ describe 'augeas::lens' do let(:facts) do facts.merge({ :augeasversion => :undef, + :puppetversion => Puppet.version, }) end @@ -35,9 +36,7 @@ describe 'augeas::lens' do 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, /You must set either \$lens_source or \$lens_content/) + expect { is_expected.to compile }.to raise_error(/You must set either \$lens_source or \$lens_content/) end end @@ -48,9 +47,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 +61,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 @@ -81,7 +80,7 @@ describe 'augeas::lens' do "class { '::augeas': version => '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 @@ -99,7 +98,7 @@ describe 'augeas::lens' do 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'" diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index c5b11ae..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 |