abessifi.java
Ansible Java Role
Description
This Ansible role installs Oracle/OpenJDK Java on various GNU/Linux systems.
Supported Systems
- Debian
- Ubuntu
- RedHat
- CentOS
- FreeBSD
Requirements
- Ansible 1.9 or newer (Install using pip:sudo pip install ansible==1.9.2)
- Vagrant 1.7 or newer
- sshpasspackage for password-based SSH authentication. To install on Ubuntu/Debian:- $ sudo apt-get install sshpass
- Virtualbox
- Oh-my-box tool (optional). It helps quickly set up and package a Vagrant box with Ansible and Ruby pre-installed.
Role Variables
Here are the available variables and their default values:
- java_jdk_type: Type of Java Development Toolkit, either- oracleor- openjdk(default: 'openjdk')
- java_version: Version of Java to install (default: '8')
- java_package: Name of the Java JDK package to install (default: None)
- java_set_as_default: If true, sets the installed Java as the system default version (default: false)
- oracle_jdk_rpm_package: RPM package name for Oracle JDK on RedHat (default: 'jdk-8u144-linux-x64.rpm')
- oracle_jdk_rpm_url: Download URL for the Oracle JDK RPM package (default: 'http://download.oracle.com/otn-pub/java/jdk/8u144-b01/jdk-8u144-linux-x64.rpm')
- rpm_download_directory: Path to the temporary directory for downloading the package (default: '/var/cache/yum/x86_64/7/extras/packages')
Available tags
- install-java: Default tag for Java JDK installation.
Usage
Install OpenJDK 8 (default is openjdk)
- hosts: localhost
  sudo: yes
  roles:
    - ansible-java
Install Oracle JDK 8 (default is oracle jdk)
- hosts: localhost
  sudo: yes
  roles:
    - { role: ansible-java, java_jdk_type: 'oracle' }
Install OpenJDK 7 (on Debian and set as default)
- hosts: localhost
  sudo: yes
  roles:
    - role: ansible-java
      java_version: 7
      java_package: 'openjdk-7-jdk'
      java_set_as_default: true
Install Oracle JDK 7 (on RedHat and set as default)
- 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
Development and Testing
Test with Vagrant
You can quickly test by creating a Debian VM with Vagrant. Adjust the Vagrantfile to fit your needs (like IP addresses).
$ vagrant up
Run Acceptance Tests
You can run acceptance/integration tests for the role using the test-kitchen tool. Test files are located in the ./test/integration/ directory.
The .kitchen.yml file describes the testing setup and test suites. By default, instances will be set up with Ansible in Vagrant VMs.
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 tests with the suite override-java-version on Debian 8, use:
$ kitchen test override-java-version-debian-8-x64
Author
This role was created by Ahmed Bessifi, a DevOps enthusiast.
Installa
 ansible-galaxy install abessifi.javaLicenza
 
            mit
          
Download
 
            425
          
Proprietario
 I’m a tech enthusiast who breathes code and loves creating beautiful software. I’m an active contributor to opensource projects and maintain a few of my own.
