This is an Ansible role to install Oracle/OpenJDK Java on several GNU/Linux systems.
- Debian
- Ubuntu
- RedHat
- CentOS
- FreeBSD
- Ansible 1.9 or higher (can be easily installed via
pip
. E.g:sudo pip install ansible==1.9.2
) - Vagrant 1.7 or higher
sshpass
package which is needed by Ansible if you are using SSH authentication by password. On Ubuntu/Debian:$ sudo apt-get install sshpass
- Virtualbox
- Oh-my-box tool, optional, if you want to quickly provision and package a Vagrant base box with Ansible and Ruby pre-installed.
Available variables are listed below, along with default values:
java_jdk_type
- The Java Development Toolkit type should beoracle
oropenjdk
(default: 'openjdk')java_version
- The Java version to install (default: '8')java_package
- The Java JDK package name to install (default: None)java_set_as_default
- If true, it sets the currently installed Java as system default version (default: false)oracle_jdk_rpm_package
- The rpm package name to install oracle jdk on Redhat (default: 'jdk-8u144-linux-x64.rpm')oracle_jdk_rpm_url
- The download url of the oracle jdk rpm package (default: 'http://download.oracle.com/otn-pub/java/jdk/8u144-b01/jdk-8u144-linux-x64.rpm')rpm_download_directory
- The absolute path to a temporary directory where the package will be downloaded to (default: '/var/cache/yum/x86_64/7/extras/packages')
install-java
- Default tag to perform Java JDK installation.
- hosts: localhost
sudo: yes
roles:
- ansible-java
- hosts: localhost
sudo: yes
roles:
- { role: ansible-java, java_jdk_type: 'oracle' }
- hosts: localhost
sudo: yes
roles:
- role: ansible-java
java_version: 7
java_package: 'openjdk-7-jdk'
java_set_as_default: true
- hosts: localhost
sudo: yes
roles:
- role: ansible-java
java_jdk_type: 'oracle'
java_version: 7
oracle_jdk_rpm_package: 'jdk-7u79-linux-x64.rpm'
oracle_jdk_rpm_url: 'http://download.oracle.com/otn-pub/java/jdk/7u79-b15/jdk-7u79-linux-x64.rpm'
java_set_as_default: true
For quick tests, you can spinup a Debian VM using Vagrant. You maybe need to adapt the Vagrantfile to suit your environment (IP addresses, etc).
$ vagrant up
Acceptance/Integration tests could be run against the role using the magic test-kitchen
tool. All the written acceptance tests are in the ./test/integration/ directory.
The .kitchen.yml
file discribes the testing configuration and the list of tests suite to run. By default, your instances will be converged with Ansible and run in Vagrant virtual machines.
To list the instances:
$ kitchen list
Instance Driver Provisioner Verifier Transport Last Action
default-debian-8-x64 Vagrant AnsiblePlaybook Busser Ssh <Not Created>
override-java-version-debian-8-x64 Vagrant AnsiblePlaybook Busser Ssh <Not Created>
install-oracle-jdk-debian-8-x64 Vagrant AnsiblePlaybook Busser Ssh <Not Created>
To run the tests with the suite override-java-version on a Debian 8 platform, for instance, run the following:
$ kitchen test override-java-version-debian-8-x64
This role was created by Ahmed Bessifi, a DevOps enthusiast.