Ansible role to manage installation of OpenJDK / Oracle JDK 6, 7 and 8.
Clone or download
zeelax and smola support for ansible 1.9.x/2.x (#17)
* Support current ansible versions.
* Remove unneeded newlines.
Latest commit 4b1184f Jan 5, 2017
Failed to load latest commit information.
defaults Initial commit. Jul 30, 2014
meta support for ansible 1.9.x/2.x (#17) Jan 5, 2017
tasks support for ansible 1.9.x/2.x (#17) Jan 5, 2017
tests Initial commit. Jul 30, 2014
vars Initial commit. Jul 30, 2014
.travis.yml Depend on Ansible >=1.6.3. Jul 30, 2014
LICENSE Initial commit. Jul 30, 2014 Initial commit. Jul 30, 2014

Ansible Java Role

Build Status

Manages installation of Java JREs and JDKs. It supports both OpenJDK and Oracle JRE and JDK 6, 7 and 8. All of them are installed using the package manager.



Role Variables

The java_packages variable must be set to a list of the desired Java packages. For example:

  - openjdk-6-jdk
  - oracle-java7-installer

Debian / Ubuntu

Valid packages for Debian and Ubuntu are:

  • openjdk-6-jre
  • openjdk-6-jre-headless
  • openjdk-6-jdk
  • openjdk-7-jre
  • openjdk-7-jre-headless
  • openjdk-7-jdk
  • oracle-java6-installer
  • oracle-java7-installer
  • oracle-java8-installer

32bit Java may be installed on x86 platforms appending :i386 to the package name.

You can ensure that Oracle JDK is set as the default JDK by adding oracle-java6-set-default, oracle-java7-set-default or oracle-java6-set-default to the java\_packages list.


Valid packages for Fedora are:

  • java-1.7.0-openjdk
  • java-1.8.0-openjdk


Got this role working with a different distro? Please, report it on GitHub or drop me a line at



Example Playbook

- hosts: servers
     - { role: }


Copyright (c) Santiago M. Mola

ansible-java-role is released under the terms of the MIT License.


Thanks to Jeff Geerling (@geerlingguy) from whom I have borrowed some ideas from his ansible-java-role and Testing Ansible Roles with Travis CI on GitHub.