From 4ec675c8ee6f695f7039230c7193b57b7de9cc55 Mon Sep 17 00:00:00 2001 From: Elyse Salberg Date: Thu, 6 Sep 2018 02:13:33 -0400 Subject: [PATCH] Allow custom target for ant installation --- manifests/init.pp | 26 +++++++++++++++----------- manifests/ivy.pp | 20 ++++++++++++-------- manifests/lib.pp | 9 +++++++-- manifests/params.pp | 7 ++++--- 4 files changed, 38 insertions(+), 24 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index cb1a8e5..c226eaf 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -3,7 +3,11 @@ # ==Parameters # # [version] The Ant version to install. -class ant($version = $ant::params::version) inherits ant::params { +# [target] The destination for the Ant install. Defaults to '/usr/share'. +class ant( + $version = $ant::params::version, + $target = $ant::params::target, +) inherits ant::params { $srcdir = $ant::params::srcdir case $::kernel { @@ -17,19 +21,19 @@ 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': + } + -> exec { 'unpack-ant': command => "tar zxvf ${srcdir}/apache-ant-${version}-bin.tar.gz", - cwd => '/usr/share/', - creates => "/usr/share/apache-ant-${version}", + cwd => $target, + creates => "${target}/apache-ant-${version}", path => '/bin/:/usr/bin', - } -> - file { '/usr/bin/ant': + } + -> file { '/usr/bin/ant': ensure => link, - target => "/usr/share/apache-ant-${version}/bin/ant", - } -> - file { '/usr/share/ant': + target => "${target}/apache-ant-${version}/bin/ant", + } + -> file { "${target}/ant": ensure => link, - target => "/usr/share/apache-ant-${version}", + target => "${target}/apache-ant-${version}", } } diff --git a/manifests/ivy.pp b/manifests/ivy.pp index 62425fa..351bc9e 100644 --- a/manifests/ivy.pp +++ b/manifests/ivy.pp @@ -3,22 +3,26 @@ # ==Parameters # # [version] The Ivy version to install. -class ant::ivy($version = '2.2.0') { +# [target] The destination for the Ivy install. Defaults to '/usr/share', +class ant::ivy( + $version = '2.2.0', + $target = $ant::params::target, +) { 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': + } + -> exec { 'unpack-ivy': command => "tar zxvf ${ant::srcdir}/apache-ivy-${version}-bin.tar.gz", - cwd => '/usr/share', + cwd => $target, path => '/bin/:/usr/bin', - creates => "/usr/share/apache-ivy-${version}" - } -> - file { "/usr/share/apache-ant-${ant::version}/lib/ivy-${version}.jar": + creates => "${target}/apache-ivy-${version}" + } + -> file { "${target}/apache-ant-${ant::version}/lib/ivy-${version}.jar": ensure => link, - target => "/usr/share/apache-ivy-${version}/ivy-${version}.jar", + target => "${target}/apache-ivy-${version}/ivy-${version}.jar", } } diff --git a/manifests/lib.pp b/manifests/lib.pp index b3651f8..32eb0e0 100644 --- a/manifests/lib.pp +++ b/manifests/lib.pp @@ -4,13 +4,18 @@ # # [version] The version of the library to install. # [source_url] The location of the ant library jar file. -define ant::lib($version, $source_url) { +# [target] The install destination for the ant library jar file. Defaults to '/usr/share'. +define ant::lib( + $version, + $source_url, + $target = $ant::params::target, +) { include ant::params wget::fetch { "${name}-antlib": source => $source_url, - destination => "/usr/share/apache-ant-${ant::params::version}/lib/${name}-${version}.jar", + destination => "${target}/apache-ant-${ant::params::version}/lib/${name}-${version}.jar", require => Class['ant'], } diff --git a/manifests/params.pp b/manifests/params.pp index dfc1569..5bc31d4 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -1,6 +1,7 @@ # This class is used to define default parameters for the ant module. # class ant::params { - $srcdir = '/usr/local/src' - $version = '1.8.2' -} \ No newline at end of file + $srcdir = '/usr/local/src' + $version = '1.8.2' + $target = '/usr/share' +}