Skip to content
This repository has been archived by the owner on Sep 2, 2020. It is now read-only.

Allow custom target for ant installation #11

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 15 additions & 11 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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}",
}
}
20 changes: 12 additions & 8 deletions manifests/ivy.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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",
}
}
9 changes: 7 additions & 2 deletions manifests/lib.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
}

Expand Down
7 changes: 4 additions & 3 deletions manifests/params.pp
Original file line number Diff line number Diff line change
@@ -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'
}
$srcdir = '/usr/local/src'
$version = '1.8.2'
$target = '/usr/share'
}