diff --git a/manifests/maven.pp b/manifests/maven.pp index c98af4c..3013f37 100644 --- a/manifests/maven.pp +++ b/manifests/maven.pp @@ -30,6 +30,7 @@ # class maven::maven( $version = '3.2.5', + $basedir = '/opt', $repo = { #url => 'http://repo1.maven.org/maven2', #username => '', @@ -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 @@ -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, } }