I'm trying to write a puppet module to install Java 8 on a virtual machine. With Java 6 it was not a problem: I wrote a java.pp with more or less these lines and everything worked correctly.
class java_6 {
package { "openjdk-6-jdk":
ensure => installed,
require => Exec["update-package-list"],
}}
I tried with some tutorial online, but everything seems to be more complex than I need. Do you have some idea how to obtain Java 8 installed on VM through Puppet?
java8.pp
for Ubuntu:
case $::operatingsystem {
ubuntu: {
include apt
apt::ppa { 'ppa:openjdk-r/ppa':
ensure => present,
}
exec { 'apt-update':
command => '/usr/bin/apt-get update',
require => [
Apt::Ppa['ppa:openjdk-r/ppa']
],
}
package { 'openjdk-8-jdk':
require => [
Exec['apt-update'],
Apt::Ppa['ppa:openjdk-r/ppa'],
],
}
}
default: {
notice "Unsupported operatingsystem ${::operatingsystem}"
}
}
This java8.pp file depends on apt module, which has to be installed on your machine.
sudo puppet module install puppetlabs-apt
sudo puppet apply java8.pp
Running java -version
to verify:
ravitezu@Lenevo:~/Workspace/Puppet$ java -version
openjdk version "1.8.0_91"
OpenJDK Runtime Environment (build 1.8.0_91-8u91-b14-0ubuntu4~16.04.1-b14)
OpenJDK 64-Bit Server VM (build 25.91-b14, mixed mode)
You do not necessarily need to build a module yourself to have Java8 running, most recommended ways is to let master do it and use modules like the puppetlabs-java puppet module, latest update can install Java 8 with simple class
class { 'java' :
distribution => 'jdk',
package => 'java-1.8.0-openjdk-devel'
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.