Skip to content
This repository has been archived by the owner on Aug 9, 2021. It is now read-only.

Commit

Permalink
add ability to purge old jars
Browse files Browse the repository at this point in the history
  • Loading branch information
jlambert121 committed Sep 3, 2013
1 parent 2866d35 commit 053b5c2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
3 changes: 2 additions & 1 deletion manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
$version = false,
$provider = 'package',
$jarfile = undef,
$purge_jars = true,
$installpath = $logstash::params::installpath,
$java_install = false,
$java_package = undef,
Expand All @@ -105,7 +106,7 @@
}

# autoupgrade
validate_bool($autoupgrade)
validate_bool($autoupgrade, $purge_jars)

# service status
if ! ($status in [ 'enabled', 'disabled', 'running', 'unmanaged' ]) {
Expand Down
20 changes: 11 additions & 9 deletions manifests/package.pp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
}

} else {

# install specific version
$package_ensure = $logstash::version

Expand Down Expand Up @@ -73,6 +72,8 @@
fail('logstash need installpath argument when using custom provider')
}

$jardir = "${logstash::installpath}/jars"

# Create directory to place the jar file
exec { 'create_install_dir':
cwd => '/',
Expand All @@ -82,9 +83,10 @@
}

# Purge old jar files
file { $logstash::installpath:
purge => true,
force => true,
file { $jardir:
ensure => 'directory',
purge => $logstash::purge_jars,
force => $logstash::purge_jars,
require => Exec['create_install_dir'],
}

Expand All @@ -106,20 +108,20 @@
case $protocol_type {
puppet: {

file { "${logstash::installpath}/${basefilename}":
file { "${jardir}/${basefilename}":
ensure => present,
source => $logstash::jarfile,
require => Exec['create_install_dir'],
require => File[$jardir],
backup => false,
}

File["${logstash::installpath}/${basefilename}"] -> File["${logstash::installpath}/logstash.jar"]
File["${jardir}/${basefilename}"] -> File["${logstash::installpath}/logstash.jar"]

}
ftp, https, http: {

exec { 'download-logstash':
command => "wget -O ${logstash::installpath}/${basefilename} ${logstash::jarfile} 2> /dev/null",
command => "wget -O ${jardir}/${basefilename} ${logstash::jarfile} 2> /dev/null",
path => ['/usr/bin', '/bin'],
creates => "${logstash::installpath}/${basefilename}",
require => Exec['create_install_dir'],
Expand All @@ -136,7 +138,7 @@
# Create symlink
file { "${logstash::installpath}/logstash.jar":
ensure => 'link',
target => "${logstash::installpath}/${basefilename}",
target => "${jardir}/${basefilename}",
backup => false
}

Expand Down

0 comments on commit 053b5c2

Please sign in to comment.