Skip to content

Commit

Permalink
Added option for local tarball cache for faster dev. Fixed path to us…
Browse files Browse the repository at this point in the history
…e parameter
  • Loading branch information
tylerwalts committed Aug 25, 2013
1 parent 55e4580 commit 9d888d6
Showing 1 changed file with 30 additions and 10 deletions.
40 changes: 30 additions & 10 deletions manifests/init.pp
Original file line number Diff line number Diff line change
@@ -1,24 +1,44 @@
# Installs the Oracle Java 7 JDK
#
# The puppet cache flages is for faster local vagrant development, to
# locally host the tarball from oracle instead of fetching it each time.
#
class jdk_oracle(
$java_install_dir ="/opt",
$java_install_dir = "/opt",
$use_cache = "false"
) {

# Set in this scope to be accessible from elsewhere
$java_home = "$java_install_dir/jdk1.7.0"

exec { 'get_jdk_tarball':
cwd => "/opt",
creates => "/opt/jdk-7-linux-x64.tar.gz",
path => ["/usr/bin", "/usr/sbin", "/bin"],
command => "wget -c --no-cookies --no-check-certificate --header \"Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com\" \"http://download.oracle.com/otn-pub/java/jdk/7/jdk-7-linux-x64.tar.gz\" -O jdk-7-linux-x64.tar.gz",
timeout => 600,
require => Package['wget'],

if ( "$use_cache" == "true" ){
notify { 'Using local cache for oracle java': }
file { "$java_install_dir/jdk-7-linux-x64.tar.gz":
source => 'puppet:///modules/jdk_oracle/jdk-7-linux-x64.tar.gz'
}
exec { 'get_jdk_tarball':
cwd => "$java_install_dir",
creates => "$java_install_dir/jdk_from_cache",
command => "touch jdk_from_cache",
path => ["/usr/bin", "/usr/sbin", "/bin"],
require => File["$java_install_dir/jdk-7-linux-x64.tar.gz"],
}
} else {
exec { 'get_jdk_tarball':
cwd => "$java_install_dir",
creates => "$java_install_dir/jdk-7-linux-x64.tar.gz",
path => ["/usr/bin", "/usr/sbin", "/bin"],
command => "wget -c --no-cookies --no-check-certificate --header \"Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com\" \"http://download.oracle.com/otn-pub/java/jdk/7/jdk-7-linux-x64.tar.gz\" -O jdk-7-linux-x64.tar.gz",
timeout => 600,
require => Package['wget'],
}
}

exec { 'extract_jdk':
cwd => "/opt/",
cwd => "$java_install_dir/",
command => "tar -xf jdk-7-linux-x64.tar.gz",
creates => "/opt/jdk1.7.0",
creates => "$java_install_dir/jdk1.7.0",
path => ["/usr/bin", "/usr/sbin", "/bin"],
require => Exec['get_jdk_tarball'],
}
Expand Down

0 comments on commit 9d888d6

Please sign in to comment.