From 7bfda059655817f7f381cb931334e2a890e54345 Mon Sep 17 00:00:00 2001 From: Asier Aguado Date: Mon, 8 Apr 2019 10:46:32 +0200 Subject: [PATCH] Replace wget with archive --- .sync.yml | 4 +- Gemfile.lock | 368 +++++++++++++-------------------- Puppetfile | 3 +- Puppetfile.lock | 4 +- manifests/maven.pp | 47 +++-- metadata.json | 4 +- spec/classes/maven_spec.rb | 12 +- spec/spec_helper.rb | 3 +- spec/spec_helper_acceptance.rb | 2 +- 9 files changed, 177 insertions(+), 270 deletions(-) diff --git a/.sync.yml b/.sync.yml index 048f545..bc6fca4 100644 --- a/.sync.yml +++ b/.sync.yml @@ -2,8 +2,8 @@ Gemfile: puppet_version: '>= 3.0' spec/spec_helper_acceptance.rb: modules: - - name: maestrodev-wget - version: 1.0.0 + - name: puppet-archive + version: 3.2.1 osfamily: RedHat - name: puppetlabs-java version: 1.0.1 diff --git a/Gemfile.lock b/Gemfile.lock index 08ec152..163aae7 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,259 +1,164 @@ GEM remote: https://rubygems.org/ specs: - CFPropertyList (2.2.8) - activemodel (4.2.0) - activesupport (= 4.2.0) - builder (~> 3.1) - activesupport (4.2.0) - i18n (~> 0.7) - json (~> 1.7, >= 1.7.7) - minitest (~> 5.1) - thread_safe (~> 0.3, >= 0.3.4) - tzinfo (~> 1.1) - addressable (2.3.6) - archive-tar-minitar (0.5.2) - autoparse (0.3.3) - addressable (>= 2.3.1) - extlib (>= 0.9.15) - multi_json (>= 1.0.0) - aws-sdk (1.61.0) - aws-sdk-v1 (= 1.61.0) - aws-sdk-v1 (1.61.0) - json (~> 1.4) - nokogiri (>= 1.4.4) - beaker (2.2.0) - aws-sdk (~> 1.57) - docker-api - fission (~> 0.4) - fog (~> 1.25) - google-api-client (~> 0.7) - hocon (~> 0.0.4) - inifile (~> 2.0) - json (~> 1.8) + beaker (4.6.0) + beaker-hostgenerator + hocon (~> 1.0) + in-parallel (~> 0.1) + inifile (~> 3.0) + minitar (~> 0.6) minitest (~> 5.4) net-scp (~> 1.2) - net-ssh (~> 2.9) - rbvmomi (~> 1.8) - unf (~> 0.1) - beaker-rspec (5.0.0) - beaker (~> 2.0) - rspec + net-ssh (~> 4.0) + open_uri_redirections (~> 0.2.1) + pry-byebug (~> 3.4.2) + rb-readline (~> 0.5.3) + rsync (~> 1.0.9) + stringify-hash (~> 0.0) + thor (~> 0.19) + beaker-hostgenerator (1.1.26) + deep_merge (~> 1.0) + stringify-hash (~> 0.0.0) + beaker-rspec (6.2.4) + beaker (> 3.0) + rspec (~> 3.0) serverspec (~> 2) specinfra (~> 2) - builder (3.2.2) - diff-lcs (1.2.5) - docile (1.1.5) - docker-api (1.17.0) - archive-tar-minitar - excon (>= 0.38.0) - json - excon (0.43.0) - extlib (0.9.16) - facter (2.3.0) - CFPropertyList (~> 2.2.6) - faraday (0.9.1) + byebug (9.0.6) + coderay (1.1.2) + deep_merge (1.2.1) + diff-lcs (1.3) + docile (1.3.1) + domain_name (0.5.20180417) + unf (>= 0.0.5, < 1.0.0) + facter (2.5.1) + faraday (0.13.1) multipart-post (>= 1.2, < 3) - fission (0.5.0) - CFPropertyList (~> 2.2) - fog (1.27.0) - fog-atmos - fog-aws (~> 0.0) - fog-brightbox (~> 0.4) - fog-core (~> 1.27, >= 1.27.3) - fog-ecloud - fog-json - fog-profitbricks - fog-radosgw (>= 0.0.2) - fog-sakuracloud (>= 0.0.4) - fog-serverlove - fog-softlayer - fog-storm_on_demand - fog-terremark - fog-vmfusion - fog-voxel - fog-xml (~> 0.1.1) - ipaddress (~> 0.5) - nokogiri (~> 1.5, >= 1.5.11) - fog-atmos (0.1.0) - fog-core - fog-xml - fog-aws (0.0.6) - fog-core (~> 1.27) - fog-json (~> 1.0) - fog-xml (~> 0.1) - ipaddress (~> 0.8) - fog-brightbox (0.7.1) - fog-core (~> 1.22) - fog-json - inflecto (~> 0.0.2) - fog-core (1.27.3) - builder - excon (~> 0.38) - formatador (~> 0.2) - mime-types - net-scp (~> 1.1) - net-ssh (>= 2.1.3) - fog-ecloud (0.0.2) - fog-core - fog-xml - fog-json (1.0.0) - multi_json (~> 1.0) - fog-profitbricks (0.0.1) - fog-core - fog-xml - nokogiri - fog-radosgw (0.0.3) - fog-core (>= 1.21.0) - fog-json - fog-xml (>= 0.0.1) - fog-sakuracloud (0.1.1) - fog-core - fog-json - fog-serverlove (0.1.1) - fog-core - fog-json - fog-softlayer (0.3.30) - fog-core - fog-json - fog-storm_on_demand (0.1.0) - fog-core - fog-json - fog-terremark (0.0.3) - fog-core - fog-xml - fog-vmfusion (0.0.1) - fission - fog-core - fog-voxel (0.0.2) - fog-core - fog-xml - fog-xml (0.1.1) - fog-core - nokogiri (~> 1.5, >= 1.5.11) - formatador (0.2.5) - google-api-client (0.8.2) - activesupport (>= 3.2) - addressable (~> 2.3) - autoparse (~> 0.3) - extlib (~> 0.9) - faraday (~> 0.9) - launchy (~> 2.4) - multi_json (~> 1.10) - retriable (~> 1.4) - signet (~> 0.6) - her (0.7.3) - activemodel (>= 3.0.0, <= 4.2) - activesupport (>= 3.0.0, <= 4.2) - faraday (>= 0.8, < 1.0) - multi_json (~> 1.7) - hiera (1.3.4) - json_pure - highline (1.6.21) - hocon (0.0.6) - i18n (0.7.0) - inflecto (0.0.2) - inifile (2.0.2) - ipaddress (0.8.0) - json (1.8.2) - json_pure (1.8.2) - jwt (1.2.0) - launchy (2.4.3) - addressable (~> 2.3) - librarian (0.1.2) - highline - thor (~> 0.15) - librarian-puppet (2.0.1) - librarian (>= 0.1.2) - puppet_forge + faraday_middleware (0.12.2) + faraday (>= 0.7.4, < 1.0) + fast_gettext (1.1.2) + gettext (3.2.9) + locale (>= 2.0.5) + text (>= 1.3.0) + gettext-setup (0.30) + fast_gettext (~> 1.1.0) + gettext (>= 3.0.2) + locale + hiera (3.5.0) + hocon (1.2.5) + http-cookie (1.0.3) + domain_name (~> 0.5) + httpclient (2.8.3) + in-parallel (0.1.17) + inifile (3.0.0) + json (2.2.0) + librarian-puppet (3.0.0) + librarianp (>= 0.6.3) + puppet_forge (~> 2.1) rsync + librarianp (0.6.4) + thor (~> 0.15) + locale (2.1.2) metaclass (0.0.4) - mime-types (2.4.3) - mini_portile (0.6.2) - minitest (5.5.1) - mocha (1.1.0) + method_source (0.9.2) + mime-types (3.2.2) + mime-types-data (~> 3.2015) + mime-types-data (3.2019.0331) + minitar (0.8) + minitest (5.11.3) + mocha (1.8.0) metaclass (~> 0.0.1) - multi_json (1.10.1) + multi_json (1.13.1) multipart-post (2.0.0) net-scp (1.2.1) net-ssh (>= 2.6.5) - net-ssh (2.9.2) - netrc (0.10.2) - nokogiri (1.6.5) - mini_portile (~> 0.6.0) - puppet (3.7.3) - facter (> 1.6, < 3) - hiera (~> 1.0) - json_pure - puppet-blacksmith (3.1.1) - puppet (>= 2.7.16) - rest-client - puppet-lint (1.1.0) - puppet-syntax (1.4.1) - rake - puppet_forge (1.0.4) - her (~> 0.6) - puppetlabs_spec_helper (0.8.2) - mocha - puppet-lint - puppet-syntax + net-ssh (4.2.0) + net-telnet (0.1.1) + netrc (0.11.0) + open_uri_redirections (0.2.1) + pathspec (0.2.1) + pry (0.12.2) + coderay (~> 1.1.0) + method_source (~> 0.9.0) + pry-byebug (3.4.3) + byebug (>= 9.0, < 9.1) + pry (~> 0.10) + puppet (6.4.0) + facter (> 2.0.1, < 4) + fast_gettext (~> 1.1.2) + hiera (>= 3.2.1, < 4) + httpclient (~> 2.8) + locale (~> 2.1) + multi_json (~> 1.10) + puppet-resource_api (~> 1.5) + semantic_puppet (~> 1.0) + puppet-blacksmith (4.1.2) + rest-client (~> 2.0) + puppet-lint (2.3.6) + puppet-resource_api (1.8.1) + hocon (>= 1.0) + puppet-syntax (2.4.3) rake - rspec - rspec-puppet - rake (10.4.2) - rbvmomi (1.8.2) - builder - nokogiri (>= 1.4.1) - trollop - rest-client (1.7.2) - mime-types (>= 1.16, < 3.0) - netrc (~> 0.7) - retriable (1.4.1) - rspec (3.1.0) - rspec-core (~> 3.1.0) - rspec-expectations (~> 3.1.0) - rspec-mocks (~> 3.1.0) - rspec-core (3.1.7) - rspec-support (~> 3.1.0) - rspec-expectations (3.1.2) + puppet_forge (2.2.9) + faraday (>= 0.9.0, < 0.14.0) + faraday_middleware (>= 0.9.0, < 0.13.0) + gettext-setup (~> 0.11) + minitar + semantic_puppet (~> 1.0) + puppetlabs_spec_helper (2.14.1) + mocha (~> 1.0) + pathspec (~> 0.2.1) + puppet-lint (~> 2.0) + puppet-syntax (~> 2.0) + rspec-puppet (~> 2.0) + rake (12.3.2) + rb-readline (0.5.5) + rest-client (2.0.2) + http-cookie (>= 1.0.2, < 2.0) + mime-types (>= 1.16, < 4.0) + netrc (~> 0.8) + rspec (3.8.0) + rspec-core (~> 3.8.0) + rspec-expectations (~> 3.8.0) + rspec-mocks (~> 3.8.0) + rspec-core (3.8.0) + rspec-support (~> 3.8.0) + rspec-expectations (3.8.2) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.1.0) - rspec-its (1.1.0) + rspec-support (~> 3.8.0) + rspec-its (1.2.0) rspec-core (>= 3.0.0) rspec-expectations (>= 3.0.0) - rspec-mocks (3.1.3) - rspec-support (~> 3.1.0) - rspec-puppet (1.0.1) + rspec-mocks (3.8.0) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.8.0) + rspec-puppet (2.7.3) rspec - rspec-support (3.1.2) + rspec-support (3.8.0) rsync (1.0.9) - serverspec (2.7.1) + semantic_puppet (1.0.2) + serverspec (2.41.3) multi_json rspec (~> 3.0) rspec-its - specinfra (~> 2.10) - signet (0.6.0) - addressable (~> 2.3) - extlib (~> 0.9) - faraday (~> 0.9) - jwt (~> 1.0) - multi_json (~> 1.10) - simplecov (0.9.1) - docile (~> 1.1.0) - multi_json (~> 1.0) - simplecov-html (~> 0.8.0) - simplecov-html (0.8.0) - specinfra (2.11.5) + specinfra (~> 2.72) + sfl (2.3) + simplecov (0.16.1) + docile (~> 1.1) + json (>= 1.8, < 3) + simplecov-html (~> 0.10.0) + simplecov-html (0.10.2) + specinfra (2.77.0) net-scp - net-ssh - thor (0.19.1) - thread_safe (0.3.4) - trollop (2.1.1) - tzinfo (1.2.2) - thread_safe (~> 0.1) + net-ssh (>= 2.7) + net-telnet (= 0.1.1) + sfl + stringify-hash (0.0.2) + text (1.3.1) + thor (0.20.3) unf (0.1.4) unf_ext - unf_ext (0.0.6) + unf_ext (0.0.7.5) PLATFORMS ruby @@ -268,3 +173,6 @@ DEPENDENCIES rake rspec-puppet (>= 1.0.0) simplecov + +BUNDLED WITH + 2.0.1 diff --git a/Puppetfile b/Puppetfile index 8f3a226..b991a4a 100644 --- a/Puppetfile +++ b/Puppetfile @@ -1,3 +1,2 @@ forge 'http://forge.puppetlabs.com' - -mod 'maestrodev/wget', '>=1.0.0' +mod 'puppet/archive', '>=1.2.0' \ No newline at end of file diff --git a/Puppetfile.lock b/Puppetfile.lock index 4b21f01..c49f675 100644 --- a/Puppetfile.lock +++ b/Puppetfile.lock @@ -1,8 +1,8 @@ FORGE remote: http://forge.puppetlabs.com specs: - maestrodev/wget (1.1.0) + puppet/archive (3.2.1) DEPENDENCIES - maestrodev/wget (>= 1.0.0) + puppet/archive (>= 1.2.0) diff --git a/manifests/maven.pp b/manifests/maven.pp index c98af4c..ff9cf0d 100644 --- a/manifests/maven.pp +++ b/manifests/maven.pp @@ -38,20 +38,20 @@ $archive = "/tmp/apache-maven-${version}-bin.tar.gz" - # prior to puppet 3.5.0, defined() couldn't test if a variable was defined. - # strict_variables wasn't added until 3.5.0, so this should be fine. - if $::puppetversion and versioncmp($::puppetversion, '3.5.0') < 0 { - $xfacts = { - 'maven_version' => $::maven_version, - } - } else { - # Strict variables facts lookup compatibility - $xfacts = { - 'maven_version' => defined('$maven_version') ? { - true => $::maven_version, - default => undef, - } - } + # prior to puppet 3.5.0, defined() couldn't test if a variable was defined. + # strict_variables wasn't added until 3.5.0, so this should be fine. + if $::puppetversion and versioncmp($::puppetversion, '3.5.0') < 0 { + $xfacts = { + 'maven_version' => $::maven_version, + } + } else { + # Strict variables facts lookup compatibility + $xfacts = { + 'maven_version' => defined('$maven_version') ? { + true => $::maven_version, + default => undef, + } + } } # Avoid redownloading when tmp tar.gz is deleted @@ -60,18 +60,17 @@ # we could use puppet-stdlib function !empty(repo) but avoiding adding a new # dependency for now if "x${repo['url']}x" != 'xx' { - wget::authfetch { 'fetch-maven': - source => "${repo['url']}/org/apache/maven/apache-maven/${version}/apache-maven-${version}-bin.tar.gz", - destination => $archive, - user => $repo['username'], - password => $repo['password'], - before => Exec['maven-untar'], + archive { $archive : + ensure => present, + source => "${repo['url']}/org/apache/maven/apache-maven/${version}/apache-maven-${version}-bin.tar.gz", + username => $repo['username'], + password => $repo['password'], + before => Exec['maven-untar'], } } else { - wget::fetch { 'fetch-maven': - source => "http://archive.apache.org/dist/maven/maven-3/${version}/binaries/apache-maven-${version}-bin.tar.gz", - destination => $archive, - before => Exec['maven-untar'], + archive { $archive : + source => "http://archive.apache.org/dist/maven/maven-3/${version}/binaries/apache-maven-${version}-bin.tar.gz", + before => Exec['maven-untar'], } } exec { 'maven-untar': diff --git a/metadata.json b/metadata.json index 9d34505..ead5cd8 100644 --- a/metadata.json +++ b/metadata.json @@ -10,8 +10,8 @@ "description": "A Puppet module to download artifacts from Maven repositories", "dependencies": [ { - "name": "maestrodev/wget", - "version_requirement": ">=1.0.0" + "name": "puppet/archive", + "version_requirement": ">=1.2.0" } ], "operatingsystem_support": [ diff --git a/spec/classes/maven_spec.rb b/spec/classes/maven_spec.rb index b214f22..97429be 100644 --- a/spec/classes/maven_spec.rb +++ b/spec/classes/maven_spec.rb @@ -5,9 +5,9 @@ let(:facts) {{ :http_proxy => '', :maven_version => '', :puppetversion => Puppet.version }} context "when downloading maven", :compile do - it do should contain_wget__fetch('fetch-maven').with( + it do should contain_archive('/tmp/apache-maven-3.2.5-bin.tar.gz').with( 'source' => 'http://archive.apache.org/dist/maven/maven-3/3.2.5/binaries/apache-maven-3.2.5-bin.tar.gz', - 'user' => nil, + 'username' => nil, 'password' => nil ) end it { should contain_exec('maven-untar') } @@ -22,9 +22,9 @@ } } it 'should fetch maven with username and password' do - should contain_wget__authfetch('fetch-maven').with( + should contain_archive('/tmp/apache-maven-3.2.5-bin.tar.gz').with( 'source' => 'http://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.2.5/apache-maven-3.2.5-bin.tar.gz', - 'user' => 'u', + 'username' => 'u', 'password' => 'p') end end @@ -33,13 +33,13 @@ context "in the same version", :compile do let(:facts) {super().merge({ :maven_version => '3.2.5' })} - it { should_not contain_wget__fetch('fetch-maven') } + it { should_not contain_archive('/tmp/apache-maven-3.2.5-bin.tar.gz') } it { should_not contain_exec('maven-untar') } end context "in a different version", :compile do let(:facts) {super().merge({ :maven_version => '3.0.4' })} - it { should contain_wget__fetch('fetch-maven') } + it { should contain_archive('/tmp/apache-maven-3.2.5-bin.tar.gz') } it { should contain_exec('maven-untar') } end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 653b868..0dc8f46 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -22,7 +22,8 @@ c.before do # avoid "Only root can execute commands as other users" - Puppet.features.stubs(:root? => true) + ## the line below makes tests fail with Mocha 1.8.0 + # Puppet.features.stubs(:root? => true) end end diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb index bd46801..a8215a3 100644 --- a/spec/spec_helper_acceptance.rb +++ b/spec/spec_helper_acceptance.rb @@ -44,7 +44,7 @@ def install_puppet(host) # Install module and dependencies puppet_module_install(:source => proj_root, :module_name => File.basename(proj_root).gsub(/^puppet-/,'')) - on host, puppet('module', 'install', 'maestrodev-wget', '--version=1.0.0'), { :acceptable_exit_codes => [0,1] } if fact('osfamily') == 'RedHat' + on host, puppet('module', 'install', 'puppet-archive', '--version=3.2.1'), { :acceptable_exit_codes => [0,1] } if fact('osfamily') == 'RedHat' on host, puppet('module', 'install', 'puppetlabs-java', '--version=1.0.1'), { :acceptable_exit_codes => [0,1] } end end