From 30b2d65c5070e286636406ff68228a00a02be221 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Kr=C3=B3l?= Date: Mon, 11 Mar 2019 15:15:19 +0100 Subject: [PATCH 1/2] Replace wget to puppet archive --- .fixtures.yml | 2 +- README.md | 2 +- manifests/init.pp | 6 ++++-- manifests/package.pp | 14 ++++++++------ manifests/params.pp | 3 ++- metadata.json | 4 ++-- spec/classes/package_spec.rb | 18 +++++++++--------- spec/spec_helper_acceptance.rb | 2 +- 8 files changed, 28 insertions(+), 23 deletions(-) diff --git a/.fixtures.yml b/.fixtures.yml index e1bb544..f997dec 100644 --- a/.fixtures.yml +++ b/.fixtures.yml @@ -1,6 +1,6 @@ fixtures: forge_modules: stdlib: 'puppetlabs/stdlib' - wget: 'maestrodev/wget' + archive: 'puppet/archive' symlinks: nexus: "#{source_dir}" diff --git a/README.md b/README.md index e14c7b1..9645261 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ Install and configure Sonatype Nexus. ## Requires -* maestrodev/wget +* puppet/archive * puppetlabs/stdlib ## Usage diff --git a/manifests/init.pp b/manifests/init.pp index fd90c5b..d4d7c25 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -49,7 +49,8 @@ $nexus_data_folder = $nexus::params::nexus_data_folder, $download_folder = $nexus::params::download_folder, $manage_config = $nexus::params::manage_config, - $md5sum = $nexus::params::md5sum, + $checksum = $nexus::params::checksum, + $checksum_type = $nexus::params::checksum_type, ) inherits nexus::params { include stdlib @@ -113,7 +114,8 @@ nexus_work_dir => $real_nexus_work_dir, nexus_work_dir_manage => $nexus_work_dir_manage, nexus_work_recurse => $nexus_work_recurse, - md5sum => $md5sum, + checksum => $checksum, + checksum_type => $checksum_type, notify => Class['nexus::service'] } diff --git a/manifests/package.pp b/manifests/package.pp index 80296bc..1a7c59f 100644 --- a/manifests/package.pp +++ b/manifests/package.pp @@ -42,7 +42,8 @@ $nexus_work_recurse = $::nexus::nexus_work_recurse, $nexus_selinux_ignore_defaults = $::nexus::nexus_selinux_ignore_defaults, $download_folder = $::nexus::download_folder, - $md5sum = $::nexus::md5sum, + $checksum = $::nexus::checksum, + $checksum_type = $::nexus::checksum_type, ) { $nexus_home = "${nexus_root}/${nexus_home_dir}" @@ -68,11 +69,12 @@ # NOTE: I *think* this won't repeatedly download the file because it's # linked to an exec resource which won't be realized if a directory # already exists. - wget::fetch{ $nexus_archive: - source => $download_url, - destination => $dl_file, - source_hash => $md5sum, - before => Exec['nexus-untar'], + archive{ $nexus_archive: + source => $download_url, + path => $dl_file, + checksum => $checksum, + checksum_type => $checksum_type, + before => Exec['nexus-untar'], } exec{ 'nexus-untar': diff --git a/manifests/params.pp b/manifests/params.pp index e27739f..1888b13 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -41,5 +41,6 @@ $nexus_data_folder = undef $download_folder = '/srv' $manage_config = true - $md5sum = undef + $checksum = undef + $checksum_type = 'none' } diff --git a/metadata.json b/metadata.json index 13934a6..e2c0af5 100644 --- a/metadata.json +++ b/metadata.json @@ -41,8 +41,8 @@ "version_requirement": ">=0.0.0 <5.0.0" }, { - "name": "maestrodev/wget", - "version_requirement": ">=1.0.0 <2.0.0" + "name": "puppet/archive", + "version_requirement": ">=0.4.4 <4.0.0" } ] } diff --git a/spec/classes/package_spec.rb b/spec/classes/package_spec.rb index e2f1a23..36d2893 100644 --- a/spec/classes/package_spec.rb +++ b/spec/classes/package_spec.rb @@ -24,18 +24,18 @@ 'revision' => '01', 'version' => '2.11.2', 'download_folder' => '/srv', - 'md5sum' => '', + 'checksum' => '', } } context 'with default values' do it { should contain_class('nexus::package') } - it { should contain_wget__fetch('nexus-2.11.2-01-bundle.tar.gz').with( + it { should contain_archive('nexus-2.11.2-01-bundle.tar.gz').with( 'source' => 'http://download.sonatype.com/nexus/oss/nexus-2.11.2-01-bundle.tar.gz', - 'destination' => '/srv/nexus-2.11.2-01-bundle.tar.gz', + 'path' => '/srv/nexus-2.11.2-01-bundle.tar.gz', 'before' => 'Exec[nexus-untar]', - 'source_hash' => '', + 'checksum' => '' ) } it { should contain_exec('nexus-untar').with( @@ -74,9 +74,9 @@ } ) - should contain_wget__fetch('nexus-professional-2.11.2-01-bundle.tar.gz').with( + should contain_archive('nexus-professional-2.11.2-01-bundle.tar.gz').with( 'source' => 'http://download.sonatype.com/nexus/professional-bundle/nexus-professional-2.11.2-01-bundle.tar.gz', - 'destination' => '/srv/nexus-professional-2.11.2-01-bundle.tar.gz', + 'path' => '/srv/nexus-professional-2.11.2-01-bundle.tar.gz', ) should contain_exec('nexus-untar').with( @@ -97,11 +97,11 @@ 'md5sum' => '1234567890' } ) - should contain_wget__fetch('nexus-2.11.2-01-bundle.tar.gz').with( + should contain_archive('nexus-2.11.2-01-bundle.tar.gz').with( 'source' => 'http://download.sonatype.com/nexus/oss/nexus-2.11.2-01-bundle.tar.gz', - 'destination' => '/srv/nexus-2.11.2-01-bundle.tar.gz', + 'path' => '/srv/nexus-2.11.2-01-bundle.tar.gz', 'before' => 'Exec[nexus-untar]', - 'source_hash' => '1234567890', + 'checksum' => '1234567890', ) should contain_exec('nexus-untar').with( 'command' => 'tar zxf /srv/nexus-2.11.2-01-bundle.tar.gz --directory /srv', diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb index d5742bd..2e7d283 100644 --- a/spec/spec_helper_acceptance.rb +++ b/spec/spec_helper_acceptance.rb @@ -23,7 +23,7 @@ shell("/bin/touch #{default['puppetpath']}/hiera.yaml") shell('puppet module install puppetlabs-stdlib', { :acceptable_exit_codes => [0,1] }) shell('puppet module install puppetlabs-java', { :acceptable_exit_codes => [0,1] }) - shell('puppet module install maestrodev-wget', { :acceptable_exit_codes => [0,1] }) + shell('puppet module install puppet-archive', { :acceptable_exit_codes => [0,1] }) end end end From d42c6884b1e797467e9f98d2168eae6eea5d0d6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Kr=C3=B3l?= Date: Mon, 11 Mar 2019 15:30:20 +0100 Subject: [PATCH 2/2] Add checksum_type to unit tests --- spec/acceptance/checksum_spec.rb | 3 ++- spec/classes/package_spec.rb | 7 +++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/spec/acceptance/checksum_spec.rb b/spec/acceptance/checksum_spec.rb index cde91cd..863c345 100644 --- a/spec/acceptance/checksum_spec.rb +++ b/spec/acceptance/checksum_spec.rb @@ -11,7 +11,8 @@ class{ '::nexus': version => '2.8.0', revision => '05', - md5sum => 'e1cece1ae5eb3a12f857e2368a3e9dbc', + checksum => 'e1cece1ae5eb3a12f857e2368a3e9dbc', + checksum_type => 'md5', nexus_root => '/srv', } EOS diff --git a/spec/classes/package_spec.rb b/spec/classes/package_spec.rb index 36d2893..a7e7472 100644 --- a/spec/classes/package_spec.rb +++ b/spec/classes/package_spec.rb @@ -25,6 +25,7 @@ 'version' => '2.11.2', 'download_folder' => '/srv', 'checksum' => '', + 'checksum_type' => 'none' } } @@ -94,7 +95,8 @@ it 'should working with md5sum' do params.merge!( { - 'md5sum' => '1234567890' + 'checksum' => '1234567890', + 'checksum_type' => 'md5', } ) should contain_archive('nexus-2.11.2-01-bundle.tar.gz').with( @@ -102,7 +104,8 @@ 'path' => '/srv/nexus-2.11.2-01-bundle.tar.gz', 'before' => 'Exec[nexus-untar]', 'checksum' => '1234567890', - ) + 'checksum_type' => 'md5', + ) should contain_exec('nexus-untar').with( 'command' => 'tar zxf /srv/nexus-2.11.2-01-bundle.tar.gz --directory /srv', 'creates' => '/srv/nexus-2.11.2-01',