Skip to content
This repository was archived by the owner on Jun 2, 2019. It is now read-only.
Open
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
39 changes: 20 additions & 19 deletions manifests/maven.pp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#
class maven::maven(
$version = '3.2.5',
$basedir = '/opt',
$repo = {
#url => 'http://repo1.maven.org/maven2',
#username => '',
Expand All @@ -38,20 +39,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
Expand All @@ -76,17 +77,17 @@
}
exec { 'maven-untar':
command => "tar xf /tmp/apache-maven-${version}-bin.tar.gz",
cwd => '/opt',
creates => "/opt/apache-maven-${version}",
cwd => $basedir,
creates => "${basedir}/apache-maven-${version}",
path => ['/bin','/usr/bin'],
}

file { '/usr/bin/mvn':
ensure => link,
target => "/opt/apache-maven-${version}/bin/mvn",
target => "${basedir}/apache-maven-${version}/bin/mvn",
require => Exec['maven-untar'],
} ->
file { '/usr/local/bin/mvn':
}
-> file { '/usr/local/bin/mvn':
ensure => absent,
}
}
Expand Down