From 2ac46f0fadd031c2e2fd9fe8aa44d03f2d000eba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Deniss=20Dolbe=C5=86ovs?= Date: Tue, 1 Sep 2020 17:39:30 +0300 Subject: [PATCH] Migrate from wget to archive module to install Apache Ant --- manifests/init.pp | 42 +++++++++++++++++++++++------------------- manifests/ivy.pp | 21 +++++++++++---------- manifests/lib.pp | 14 +++++++++----- manifests/params.pp | 12 ++++++++++-- 4 files changed, 53 insertions(+), 36 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index cb1a8e5..09e6892 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -3,26 +3,30 @@ # ==Parameters # # [version] The Ant version to install. -class ant($version = $ant::params::version) inherits ant::params { - $srcdir = $ant::params::srcdir +class ant( + $version = $ant::params::version, + $srcdir = $ant::params::srcdir, + $checksum_verify = $ant::params::checksum_verify, + $checksum = $ant::params::checksum, + $proxy_server = $ant::params::proxy_server, + $proxy_type = $ant::params::proxy_type, + + ) inherits ant::params { + include 'archive' - case $::kernel { - 'Linux': { - ensure_packages(['tar']) - Package['tar'] -> Exec['unpack-ant'] - } - default: {} - } - - wget::fetch { 'ant': - source => "http://archive.apache.org/dist/ant/binaries/apache-ant-${version}-bin.tar.gz", - destination => "${srcdir}/apache-ant-${version}-bin.tar.gz" - } -> - exec { 'unpack-ant': - command => "tar zxvf ${srcdir}/apache-ant-${version}-bin.tar.gz", - cwd => '/usr/share/', - creates => "/usr/share/apache-ant-${version}", - path => '/bin/:/usr/bin', + archive { "${srcdir}/apache-ant-${version}-bin.tar.gz": + ensure => present, + extract => true, + extract_command => 'tar zxvf %s', + extract_path => '/usr/share/', + source => "https://archive.apache.org/dist/ant/binaries/apache-ant-${version}-bin.tar.gz", + creates => "/usr/share/apache-ant-${version}", + cleanup => true, + checksum_verify => $checksum_verify, + checksum_type => 'md5', + checksum => $checksum, + proxy_server => $proxy_server, + proxy_type => $proxy_type, } -> file { '/usr/bin/ant': ensure => link, diff --git a/manifests/ivy.pp b/manifests/ivy.pp index 62425fa..2709bed 100644 --- a/manifests/ivy.pp +++ b/manifests/ivy.pp @@ -6,16 +6,17 @@ class ant::ivy($version = '2.2.0') { include ant - wget::fetch { 'ivy': - source => "http://archive.apache.org/dist/ant/ivy/${version}/apache-ivy-${version}-bin.tar.gz", - destination => "${ant::srcdir}/apache-ivy-${version}-bin.tar.gz", - require => Class[ant], - } -> - exec { 'unpack-ivy': - command => "tar zxvf ${ant::srcdir}/apache-ivy-${version}-bin.tar.gz", - cwd => '/usr/share', - path => '/bin/:/usr/bin', - creates => "/usr/share/apache-ivy-${version}" + archive { "${ant::srcdir}/apache-ivy-${version}-bin.tar.gz": + ensure => present, + extract => true, + extract_command => 'tar zxvf %s', + extract_path => '/usr/share/', + source => "https://archive.apache.org/dist/ant/ivy/${version}/apache-ivy-${version}-bin.tar.gz", + creates => "/usr/share/apache-ivy-${version}", + cleanup => true, + proxy_server => $ant::params::proxy_server, + proxy_type => $ant::params::proxy_type, + require => Class['ant'], } -> file { "/usr/share/apache-ant-${ant::version}/lib/ivy-${version}.jar": ensure => link, diff --git a/manifests/lib.pp b/manifests/lib.pp index b3651f8..b12bf24 100644 --- a/manifests/lib.pp +++ b/manifests/lib.pp @@ -8,10 +8,14 @@ include ant::params - wget::fetch { "${name}-antlib": - source => $source_url, - destination => "/usr/share/apache-ant-${ant::params::version}/lib/${name}-${version}.jar", - require => Class['ant'], + archive { "/usr/share/apache-ant-${ant::params::version}/lib/${name}-${version}.jar": + ensure => present, + extract => false, + source => $source_url, + creates => "/usr/share/apache-ant-${ant::params::version}/lib/${name}-${version}.jar", + cleanup => false, + proxy_server => $ant::params::proxy_server, + proxy_type => $ant::params::proxy_type, + require => Class['ant'], } - } diff --git a/manifests/params.pp b/manifests/params.pp index dfc1569..1728228 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -1,6 +1,14 @@ # This class is used to define default parameters for the ant module. # class ant::params { - $srcdir = '/usr/local/src' - $version = '1.8.2' + $srcdir = '/usr/local/src' + $version = '1.10.8' + $checksum = undef + if $checksum == undef { + $checksum_verify = false + } else { + $checksum_verify = true + } + $proxy_server = undef + $proxy_type = undef } \ No newline at end of file