Last active
October 13, 2015 23:58
-
-
Save narkisr/4276044 to your computer and use it in GitHub Desktop.
Setting JDK on Ubuntu or Centos/Redhat systems
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Setting up sun-jdk | |
class backend::jdk { | |
if($operatingsystem =~ /Ubuntu|Debian/){ | |
include apt | |
apt::ppa { 'ppa:webupd8team/java': } | |
package{'oracle-java6-installer': | |
ensure => present, | |
require => [Apt::Ppa['ppa:webupd8team/java'],Exec['skipping license approval']] | |
} | |
exec{'skipping license approval': | |
command => "/bin/echo 'oracle-java6-installer shared/accepted-oracle-license-v1-1 boolean true' | /usr/bin/debconf-set-selections", | |
user => 'root', | |
require => Apt::Ppa['ppa:webupd8team/java'], | |
} | |
} | |
if($operatingsystem =~ /RedHat|CentOS/) { | |
$package = 'jdk-6u38-linux-x64-rpm.bin' | |
$cookie = '"Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2Ftechnetwork%2Fjava%2Fjavase%2Fdownloa ds%2Fjdk-7u3-download-1501626.html;"' | |
$url = "http://download.oracle.com/otn-pub/java/jdk/6u38-b05/${package}" | |
# http://getpocket.com/a/read/153528263 | |
exec{'download jdk': | |
command => "wget -O /tmp/${package} --no-cookies --header ${cookie} ${url}", | |
user => 'root', | |
path => '/usr/bin/' | |
} | |
exec{'chmod jdk package': | |
command => "chmod +x /tmp/${package}", | |
user => 'root', | |
path => '/bin' | |
} | |
exec{'install jdk': | |
command => "yes \"\" | /tmp/${package}", | |
user => 'root', | |
path => '/usr/bin/', | |
unless => '/usr/bin/test -d /usr/java', | |
require => [Exec['download jdk'], Exec['chmod jdk package']] | |
} | |
exec{'update alternative': | |
command => 'alternatives --install /usr/bin/java java /usr/java/jdk1.6.0_38/bin/java 2', | |
user => 'root', | |
path => '/usr/sbin/', | |
unless => '/usr/bin/which java' | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment