Skip to content

Instantly share code, notes, and snippets.

@tfnico
Last active September 16, 2018 12:56
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tfnico/6d2b57642d21ebaa7574 to your computer and use it in GitHub Desktop.
Save tfnico/6d2b57642d21ebaa7574 to your computer and use it in GitHub Desktop.
Puppet recipe for installing Java8 on Debian
class oracle_java8 {
# This follows the recipe from http://blog.nocturne.net.nz/devops/2013/08/14/provisioning-oracle-java-with-puppet-apply/
# adapted with the instructions from http://www.webupd8.org/2014/03/how-to-install-oracle-java-8-in-debian.html
# define a variable for the webupd8team ppa sources list
$webupd8src = '/etc/apt/sources.list.d/webupd8team.list'
exec {'hello':
unless => "/bin/true",
command => '/bin/echo hello world',
}
# Configure ppa
file { $webupd8src:
content => "deb http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main\ndeb-src http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main\n",
} ->
# Authorise the webupd8 ppa
# At the time of writing this key was correct, but check the PPA page on launchpad!
# https://launchpad.net/~webupd8team/+archive/java
exec { 'add-webupd8-key':
unless => "apt-key list | grep -c EEA14886 2>/dev/null",
command => 'apt-key adv --keyserver keyserver.ubuntu.com --recv-keys EEA14886',
path => ['/usr/bin/','/bin/'],
} ->
# update the apt keystore
exec { 'apt-key-update':
unless => "update-alternatives --list java|grep java-8-oracle 2>/dev/null",
command => 'apt-key update',
path => ['/usr/bin/','/bin/'],
} ->
# update apt sources
exec { 'apt-update':
unless => "update-alternatives --list java|grep java-8-oracle 2>/dev/null",
command => 'apt-get update',
path => ['/usr/bin/','/bin/'],
} ->
# set license acceptance with debconf
exec { 'accept-java-license':
unless => "update-alternatives --list java|grep java-8-oracle 2>/dev/null",
command => 'echo oracle-java8-installer shared/accepted-oracle-license-v1-1 select true | sudo /usr/bin/debconf-set-selections',
path => ['/usr/bin/','/bin/'],
} ~>
# finally install the package
# oracle-java6-installer and oracle-java7-installer also available from the ppa
package { 'oracle-java8-installer':
ensure => present,
}
}
@tfnico
Copy link
Author

tfnico commented May 28, 2014

Just updated to do stuff a bit more conditionally..

@blub0hr
Copy link

blub0hr commented Aug 16, 2016

The execution fails at line 23. To fix it, replace command with:
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys EEA14886

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment