From 755ac63105b92502fe3d1439ddfeccbfb5c0175a Mon Sep 17 00:00:00 2001 From: Elyse Salberg Date: Thu, 2 Aug 2018 16:32:36 -0400 Subject: [PATCH] Add parameters to control management of target directory and unzip package Add groovy.csh file for environment defaults --- manifests/init.pp | 54 +++++++++++++++++++++++++++++----------- manifests/params.pp | 10 +++++--- templates/groovy.csh.erb | 2 ++ 3 files changed, 48 insertions(+), 18 deletions(-) create mode 100644 templates/groovy.csh.erb diff --git a/manifests/init.pp b/manifests/init.pp index f7079f2..05d00c5 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -11,10 +11,12 @@ # Spencer Herzberg # 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 @@ -23,7 +25,27 @@ 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, @@ -31,26 +53,30 @@ 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, } } diff --git a/manifests/params.pp b/manifests/params.pp index 7acce0f..4772ddc 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -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 } diff --git a/templates/groovy.csh.erb b/templates/groovy.csh.erb new file mode 100644 index 0000000..5b5d136 --- /dev/null +++ b/templates/groovy.csh.erb @@ -0,0 +1,2 @@ +setenv GROOVY_HOME <%= @groovy_dir %> +set path=( $path "<%= @groovy_dir %>/bin" )