Skip to content

Commit

Permalink
Add parameters to control management of target directory and unzip pa…
Browse files Browse the repository at this point in the history
…ckage

Add groovy.csh file for environment defaults
  • Loading branch information
esalberg committed Aug 23, 2018
1 parent 48155d0 commit 755ac63
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 18 deletions.
54 changes: 40 additions & 14 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@
# Spencer Herzberg <[email protected]>
#
class groovy (
$version = $groovy::params::version,
$base_url = $groovy::params::base_url,
$target = $groovy::params::target,
$timeout = $groovy::params::timeout,
$version = $groovy::params::version,
$base_url = $groovy::params::base_url,
$target = $groovy::params::target,
$manage_target = $groovy::params::manage_target,
$manage_unzip = $groovy::params::manage_unzip,
$timeout = $groovy::params::timeout,
) inherits groovy::params {

include stdlib
Expand All @@ -23,34 +25,58 @@
validate_string($base_url)

$groovy_filename = "groovy-binary-${version}.zip"
$groovy_dir = "${target}/groovy-${version}"
$groovy_dir = "${target}/groovy-${version}"

if $manage_target and $manage_unzip {
$staging_require = [
Staging::File[$groovy_filename],
File[$target],
Package['unzip'],
]
} elsif $manage_target {
$staging_require = [
Staging::File[$groovy_filename],
File[$target],
]
} elsif $manage_unzip {
$staging_require = [
Staging::File[$groovy_filename],
Package['unzip'],
]
} else {
$staging_require = Staging::File[$groovy_filename]
}

file { '/etc/profile.d/groovy.sh':
ensure => file,
mode => '0644',
content => template("${module_name}/groovy.sh.erb"),
}

file { '/etc/profile.d/groovy.csh':
ensure => file,
mode => '0644',
content => template("${module_name}/groovy.csh.erb"),
}

staging::file { $groovy_filename:
source => "${base_url}/${groovy_filename}",
timeout => $timeout,
}

package { 'unzip':
ensure => present,
if $manage_unzip {
ensure_resource('package','unzip', {'ensure' => 'present' })
}

file { $target:
ensure => directory,
if $manage_target {
file { $target:
ensure => directory,
}
}

staging::extract { $groovy_filename:
target => $target,
creates => $groovy_dir,
require => [
Staging::File[$groovy_filename],
File[$target],
Package['unzip'],
],
require => $staging_require,
}
}
10 changes: 6 additions & 4 deletions manifests/params.pp
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
#
# default parameters for the groovy class
class groovy::params {
$version = '2.3.1'
$base_url = 'http://dl.bintray.com/groovy/maven/'
$target = '/opt'
$timeout = 360
$version = '2.3.1'
$base_url = 'http://dl.bintray.com/groovy/maven/'
$target = '/opt'
$manage_target = true
$manage_unzip = true
$timeout = 360
}
2 changes: 2 additions & 0 deletions templates/groovy.csh.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
setenv GROOVY_HOME <%= @groovy_dir %>
set path=( $path "<%= @groovy_dir %>/bin" )

0 comments on commit 755ac63

Please sign in to comment.