diff --git a/.fixtures.yml b/.fixtures.yml index 715cad4..7632658 100644 --- a/.fixtures.yml +++ b/.fixtures.yml @@ -1,3 +1,4 @@ +--- fixtures: symlinks: archive: "#{source_dir}" diff --git a/.gemfile b/.gemfile deleted file mode 100644 index c9713f0..0000000 --- a/.gemfile +++ /dev/null @@ -1,10 +0,0 @@ -source 'https://rubygems.org' -puppetversion = ENV.key?('PUPPET_VERSION') ? "#{ENV['PUPPET_VERSION']}" : ['~> 3.2.0'] - -gem 'puppet', puppetversion - -group :test do - gem 'rake', '>= 0.9.0' - gem 'puppetlabs_spec_helper', '>= 0.4.1' - gem 'puppet-lint' -end diff --git a/.gitignore b/.gitignore index 008b417..4749e1e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,6 @@ /metadata.json /.project +/.gemfile.lock +/.bundle/config +/pkg/* +/Gemfile.lock diff --git a/.puppet-lint.rc b/.puppet-lint.rc deleted file mode 100644 index fac18a5..0000000 --- a/.puppet-lint.rc +++ /dev/null @@ -1 +0,0 @@ ---no-80chars diff --git a/.travis.yml b/.travis.yml index 8fc3d34..610b309 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,16 +1,18 @@ +--- language: ruby -script: "rake spec lint" -rvm: - - 1.9.2 - - 1.9.3 - - 2.0.0 -env: - - PUPPET_VERSION="~> 2.7.0" - - PUPPET_VERSION="~> 3.2.0" - - PUPPET_VERSION="~> 3.4.0" +bundler_args: --without development +script: "bundle exec rake validate lint spec SPEC_OPTS='--format documentation' && bundle exec rake smoke" matrix: - exclude: - - rvm: 2.0.0 - env: PUPPET_VERSION="~> 2.7.0" -gemfile: .gemfile + fast_finish: true + include: + - rvm: 1.8.7 + env: PUPPET_GEM_VERSION="~> 2.7" + - rvm: 1.9.3 + env: PUPPET_GEM_VERSION="~> 3.0" + - rvm: 2.0.0 + env: PUPPET_GEM_VERSION="~> 3.0" + - rvm: 2.1.0 + env: PUPPET_GEM_VERSION="~> 3.7" +notifications: + email: false diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..081b1a2 --- /dev/null +++ b/Gemfile @@ -0,0 +1,27 @@ +source ENV['GEM_SOURCE'] || "https://rubygems.org" + +group :development, :test do + gem 'rake', :require => false + gem 'rspec-puppet', :require => false + gem 'puppetlabs_spec_helper', :require => false + gem 'serverspec', :require => false + gem 'puppet-lint', '0.3.2', :require => false + gem 'beaker', :require => false + gem 'beaker-rspec', :require => false + gem 'pry', :require => false + gem 'simplecov', :require => false +end + +if facterversion = ENV['FACTER_GEM_VERSION'] + gem 'facter', facterversion, :require => false +else + gem 'facter', :require => false +end + +if puppetversion = ENV['PUPPET_GEM_VERSION'] + gem 'puppet', puppetversion, :require => false +else + gem 'puppet', :require => false +end + +# vim:ft=ruby diff --git a/Modulefile b/Modulefile index ea4c0b0..17beeee 100644 --- a/Modulefile +++ b/Modulefile @@ -1,5 +1,5 @@ name 'gini-archive' -version '0.2.0' +version '0.2.2' author 'Jochen Schalanda' license 'Apache 2.0' project_page 'https://github.com/gini/puppet-archive' diff --git a/README.md b/README.md index 60811ff..4e740b3 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,9 @@ Supported Platforms The module has been tested on the following operating systems. Testing and patches for other platforms are welcome. * Debian Linux 7.0 (Wheezy) +* Ubuntu 13.04 +* RHEL 6.x +* Oracle Linux 6.x Support @@ -61,3 +64,4 @@ Contributors * Zijad Purkovic (zajk) * Martin Konrad (mark0n) * Brendan Murtagh (bmurt) +* Krzysztof SuszyƄski (cardil) diff --git a/Rakefile b/Rakefile index 26fd890..5c397d7 100644 --- a/Rakefile +++ b/Rakefile @@ -1,7 +1,16 @@ -require 'rake' require 'puppetlabs_spec_helper/rake_tasks' require 'puppet-lint/tasks/puppet-lint' -PuppetLint.configuration.send("disable_80chars") +PuppetLint.configuration.fail_on_warnings +PuppetLint.configuration.send('disable_80chars') +PuppetLint.configuration.send('disable_class_inherits_from_params_class') +PuppetLint.configuration.send('disable_class_parameter_defaults') +PuppetLint.configuration.send('disable_documentation') +PuppetLint.configuration.send('disable_single_quote_string_with_variables') +PuppetLint.configuration.ignore_paths = ["spec/**/*.pp", "pkg/**/*.pp"] -task :default => [:spec, :lint] +task :smoke do + Rake::Task[:spec_prep].invoke + sh "puppet apply tests/init.pp --noop --modulepath spec/fixtures/modules" + Rake::Task[:spec_clean].invoke +end diff --git a/manifests/init.pp b/manifests/init.pp index 948011b..98775dd 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -59,6 +59,10 @@ $dependency_class = Class['archive::prerequisites'], $exec_path = ['/usr/local/bin', '/usr/bin', '/bin']) { + if $dependency_class == Class['archive::prerequisites'] { + include archive::prerequisites + } + archive::download {"${name}.${extension}": ensure => $ensure, url => $url, @@ -86,6 +90,9 @@ timeout => $timeout, strip_components => $strip_components, exec_path => $exec_path, - require => Archive::Download["${name}.${extension}"] + require => [ + Archive::Download["${name}.${extension}"], + $dependency_class + ], } } diff --git a/spec/classes/archive_spec.rb b/spec/classes/archive_spec.rb deleted file mode 100644 index 6094ab7..0000000 --- a/spec/classes/archive_spec.rb +++ /dev/null @@ -1,3 +0,0 @@ -require 'spec_helper' - -# No specs yet. See http://rspec-puppet.com/ diff --git a/spec/spec.opts b/spec/spec.opts new file mode 100644 index 0000000..91cd642 --- /dev/null +++ b/spec/spec.opts @@ -0,0 +1,6 @@ +--format +s +--colour +--loadby +mtime +--backtrace diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index dc7e9f4..2c6f566 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,2 +1 @@ -require 'rubygems' require 'puppetlabs_spec_helper/module_spec_helper' diff --git a/spec/unit/defines/archive_spec.rb b/spec/unit/defines/archive_spec.rb new file mode 100644 index 0000000..ab9abb0 --- /dev/null +++ b/spec/unit/defines/archive_spec.rb @@ -0,0 +1,59 @@ +require 'spec_helper' +require 'rspec-puppet' + +describe 'archive', :type => :define do + context 'with filetype => zip' do + let(:title) { 'apache-tomcat-8.0.11' } + let(:params) { { + :ensure => 'present', + :url => 'http://archive.apache.org/dist/tomcat/tomcat-8/v8.0.11/bin/apache-tomcat-8.0.11.zip', + :extension => 'zip', + :username => 'example', + :password => 'example', + :target => '/opt', + } } + it { should compile } + it { should compile.with_all_deps } + it { should contain_class('archive::prerequisites') } + it { should contain_archive__download('apache-tomcat-8.0.11.zip') } + it { should contain_archive__extract('apache-tomcat-8.0.11') } + it { should contain_exec('download digest of archive apache-tomcat-8.0.11.zip') } + it { + should contain_exec('download archive apache-tomcat-8.0.11.zip and check sum').with_command( + 'curl --user example:example -s -L -o /usr/src/apache-tomcat-8.0.11.zip ' + + 'http://archive.apache.org/dist/tomcat/tomcat-8/v8.0.11/bin/apache-tomcat-8.0.11.zip' + ) + } + it { + should contain_exec('Unpack apache-tomcat-8.0.11').with_command( + 'mkdir -p /opt/apache-tomcat-8.0.11 && unzip -o /usr/src/apache-tomcat-8.0.11.zip -d /opt/apache-tomcat-8.0.11' + ) + } + end + context 'with filetype => tarball' do + let(:title) { 'apache-tomcat-8.0.11' } + let(:params) { { + :ensure => 'present', + :url => 'http://archive.apache.org/dist/tomcat/tomcat-8/v8.0.11/bin/apache-tomcat-8.0.11.tar.gz', + :target => '/usr/src', + } } + it { should compile } + it { should compile.with_all_deps } + it { should contain_class('archive::prerequisites') } + it { should contain_archive__download('apache-tomcat-8.0.11.tar.gz') } + it { should contain_archive__extract('apache-tomcat-8.0.11') } + it { should contain_exec('download digest of archive apache-tomcat-8.0.11.tar.gz') } + it { + should contain_exec('download archive apache-tomcat-8.0.11.tar.gz and check sum').with_command( + 'curl -s -L -o /usr/src/apache-tomcat-8.0.11.tar.gz ' + + 'http://archive.apache.org/dist/tomcat/tomcat-8/v8.0.11/bin/apache-tomcat-8.0.11.tar.gz' + ) + } + it { + should contain_exec('Unpack apache-tomcat-8.0.11').with_command( + 'mkdir -p /usr/src/apache-tomcat-8.0.11 && tar --no-same-owner --no-same-permissions ' + + '--strip-components=0 -xzf /usr/src/apache-tomcat-8.0.11.tar.gz -C /usr/src/apache-tomcat-8.0.11' + ) + } + end +end diff --git a/tests/init.pp b/tests/init.pp new file mode 100644 index 0000000..70df92e --- /dev/null +++ b/tests/init.pp @@ -0,0 +1,15 @@ +archive { 'apache-tomcat-6.0.26': + ensure => present, + url => 'http://archive.apache.org/dist/tomcat/tomcat-6/v6.0.26/bin/apache-tomcat-6.0.26.tar.gz', + target => '/opt', +} + +archive { 'apache-tomcat-8.0.11': + ensure => present, + url => 'http://archive.apache.org/dist/tomcat/tomcat-8/v8.0.11/bin/apache-tomcat-8.0.11.zip', + extension => 'zip', + username => 'example', + password => 'example', + target => '/opt', +} +