Skip to content

Commit

Permalink
Merge pull request #92 from ansiblebit/develop
Browse files Browse the repository at this point in the history
java 10
  • Loading branch information
steenzout authored Aug 20, 2018
2 parents 7b7a7c7 + 85aa772 commit 6f4d635
Show file tree
Hide file tree
Showing 18 changed files with 334 additions and 298 deletions.
4 changes: 4 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ sudo: yes

matrix:
include:
- python: 2.7
env: TOXENV=py27-ansible26
- python: 2.7
env: TOXENV=py27-ansible25
- python: 2.7
env: TOXENV=py27-ansible24
- python: 2.7
Expand Down
154 changes: 111 additions & 43 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
[![License](https://img.shields.io/badge/license-New%20BSD-blue.svg?style=flat)](https://raw.githubusercontent.com/ansiblebit/oracle-java/master/LICENSE)
[![Build Status](https://travis-ci.org/ansiblebit/oracle-java.svg?branch=master)](https://travis-ci.org/ansiblebit/oracle-java)

[![Platform](http://img.shields.io/badge/platform-centos-932279.svg?style=flat)](#)
[![Platform](http://img.shields.io/badge/platform-debian-a80030.svg?style=flat)](#)
[![Platform](http://img.shields.io/badge/platform-redhat-cc0000.svg?style=flat)](#)
[![Platform](http://img.shields.io/badge/platform-ubuntu-dd4814.svg?style=flat)](#)
[![Platform](http://img.shields.io/badge/platform-centos-932279.svg?style=flat)](CentOS)
[![Platform](http://img.shields.io/badge/platform-debian-a80030.svg?style=flat)](Debian)
[![Platform](http://img.shields.io/badge/platform-redhat-cc0000.svg?style=flat)](RedHat)
[![Platform](http://img.shields.io/badge/platform-ubuntu-dd4814.svg?style=flat)](Ubuntu)

[![Project Stats](https://www.openhub.net/p/ansiblebit-oracle-java/widgets/project_thin_badge.gif)](https://www.openhub.net/p/ansiblebit-oracle-java/)

Expand All @@ -15,67 +15,135 @@ An [Ansible](http://www.ansible.com) role to setup Oracle Java Development Kit.
DISCLAIMER: usage of any version of this role implies you have accepted the
[Oracle Binary Code License Agreement for Java SE](http://www.oracle.com/technetwork/java/javase/terms/license/index.html).


## Tests

| Family | Distribution | Version | Test Status |
|:-:|:-:|:-:|:-:|
| Debian | Debian | Jessie | [![x86_64](http://img.shields.io/badge/x86_64-passed-006400.svg?style=flat)](#) |
| Debian | Ubuntu | Precise | [![x86_64](http://img.shields.io/badge/x86_64-passed-006400.svg?style=flat)](#) |
| Debian | Ubuntu | Yakkety | [![x86_64](http://img.shields.io/badge/x86_64-passed-006400.svg?style=flat)](#) |
| Debian | Ubuntu | Xenial | [![x86_64](http://img.shields.io/badge/x86_64-passed-006400.svg?style=flat)](#) |
| Debian | Ubuntu | Trusty | [![x86_64](http://img.shields.io/badge/x86_64-passed-006400.svg?style=flat)](#) |
| Debian | Ubuntu | Vivid | [![x86_64](http://img.shields.io/badge/x86_64-passed-006400.svg?style=flat)](#) |
| Debian | Ubuntu | Wily | [![x86_64](http://img.shields.io/badge/x86_64-passed-006400.svg?style=flat)](#) |
| RedHat | Centos | 7 | [![x86_64](http://img.shields.io/badge/x86_64-passed-006400.svg?style=flat)](#) |
| Debian | Debian | Jessie | [![x86_64](http://img.shields.io/badge/x86_64-passed-006400.svg?style=flat)](x) |
| Debian | Debian | Stretch | [![x86_64](http://img.shields.io/badge/x86_64-passed-006400.svg?style=flat)](x) |
| Debian | Ubuntu | Precise | [![x86_64](http://img.shields.io/badge/x86_64-passed-006400.svg?style=flat)](x) |
| Debian | Ubuntu | Yakkety | [![x86_64](http://img.shields.io/badge/x86_64-passed-006400.svg?style=flat)](x) |
| Debian | Ubuntu | Xenial | [![x86_64](http://img.shields.io/badge/x86_64-passed-006400.svg?style=flat)](x) |
| Debian | Ubuntu | Trusty | [![x86_64](http://img.shields.io/badge/x86_64-passed-006400.svg?style=flat)](x) |
| Debian | Ubuntu | Vivid | [![x86_64](http://img.shields.io/badge/x86_64-passed-006400.svg?style=flat)](x) |
| Debian | Ubuntu | Wily | [![x86_64](http://img.shields.io/badge/x86_64-passed-006400.svg?style=flat)](x) |
| Debian | Ubuntu | Artful | [![x86_64](http://img.shields.io/badge/x86_64-passed-006400.svg?style=flat)](x) |
| Debian | Ubuntu | Bionic | [![x86_64](http://img.shields.io/badge/x86_64-passed-006400.svg?style=flat)](x) |
| Debian | Ubuntu | Cosmic | [![x86_64](http://img.shields.io/badge/x86_64-passed-006400.svg?style=flat)](x) |
| RedHat | Centos | 7 | [![x86_64](http://img.shields.io/badge/x86_64-passed-006400.svg?style=flat)](x) |

## Requirements

- ansible >= 2.x

## Facts

# Facts
| variable | description |
|--:|:--|
| oracle_java_installed | fact set by this role that contains a flag that indicates if Java is installed on the host. |
| oracle_java_version_installed | fact set by this role that contains the string of the Java version installed in the system. |

- **oracle_java_installed**: fact set by this role that contains a flag that indicates if Java is installed on the host.
- **oracle_java_version_installed**: fact set by this role that contains the string of the Java version installed in the system.

## Role Variables

| variable | default | description |
|--:|:-:|:--|
| debug | undefined | flag to make role more verbose. |
| oracle_java_set_as_default | yes | make the newly installed Java the default runtime environment. |
| oracle_java_state | latest | the package state (see Ansible apt module for more information). |
| oracle_java_version | 8 | the Oracle JDK version to be installed. |
| oracle_java_version_string | 1.{{ oracle_java_version }}.0_u{{ oracle_java_version_update }} | the Java version string to verify installation against. |
| oracle_java_os_supported | - | role internal variable to check if a OS family is supported or not. |
- **debug**: flag to make role more verbose.
- **oracle_java_set_as_default**: make the newly installed Java the default runtime environment (default: `yes`).
- **oracle_java_os_supported**: role internal variable to check if a OS family is supported or not.

### Debian

### Debian-only
- **oracle_java_apt_repository**: Personal Package Archive (PPA) from where to install Java (default: `deb http://ppa.launchpad.net/linuxuprising/java/ubuntu bionic main`).
- **oracle_java_apt_repository_key**: PPA repository key (default: `EA8CACC073C3DB2A`.
- **oracle_java_cache_valid_time**: the amount of time in seconds the apt cache is valid (default: `3600`).
- **oracle_java_deb_package**: name of debian package (default: `oracle-java10-installer`).
- **oracle_java_debconf_package_default**: (default: `oracle-java10-set-default`).
- **oracle_java_home**: the location of the Java home directory (default: `/usr/lib/jvm/java-10-oracle`).
- **oracle_java_state**:** the package state (see Ansible apt module for more information) (default: `latest`).

| variable | default | description |
|--:|:-:|:--|
| oracle_java_cache_valid_time | 3600 | the amount of time in seconds the apt cache is valid. |
| oracle_java_state | latest | the package state (see Ansible apt module for more information). |
| oracle_java_home | /usr/lib/jvm/java-{{ oracle_java_version }}-oracle | the location of the Java home directory. |
### Debian/Ubuntu

- **oracle_java_apt_repository**: Personal Package Archive (PPA) from where to install Java (default: `ppa:linuxuprising/java`).
- **oracle_java_cache_valid_time**: the amount of time in seconds the apt cache is valid (default: `3600`).
- **oracle_java_deb_package**: name of debian package (default: `oracle-java10-installer`).
- **oracle_java_debconf_package_default**: (default: `oracle-java10-set-default`).
- **oracle_java_home**: the location of the Java home directory (default: `/usr/lib/jvm/java-10-oracle`).
- **oracle_java_state**:** the package state (see Ansible apt module for more information) (default: `latest`).

### Redhat-only

| variable | default | description |
|--:|:-:|:--|
| oracle_java_dir_source | /usr/local/src | directory where to store the RPM files. |
| oracle_java_home | /usr/java/jdk1.{{ oracle_java_version }}.0_{{ oracle_java_version_update }} | the location of the Java home directory. |
| oracle_java_rpm_validate_certs | yes | flag to indicate if you want SSL certificate validation. |

- **oracle_java_dir_source**: directory where to store the RPM files (default: `/usr/local/src`).
- **oracle_java_download_timeout**: download timeout, in seconds (default: `60`).
- **oracle_java_download_url**: where to download the rpm from (default: `http://download.oracle.com/otn-pub/java/jdk/10.0.2+13/19aef61b38124481863b1413dce1855f/jdk-10.0.2_linux-x64_bin.rpm`).
- **oracle_java_home**: the location of the Java home directory (default: `/usr/java/default`).
- **oracle_java_rpm_filename**: file name used for the download destination (default: `jdk-10.0.2_linux-x64_bin.rpm`).
- **oracle_java_rpm_validate_certs**: flag to indicate if you want SSL certificate validation (default: `yes`).
- **oracle_java_version**: the Oracle JDK version to be installed (default: `10`).
- **oracle_java_version_string**: the Java version string to verify installation against (default: `1.{{ oracle_java_version }}.0_u{{ oracle_java_version_update }}`).

## Playbooks

- hosts: servers
roles:
- role: ansiblebit.oracle-java,
oracle_java_set_as_default: yes
```yaml
# generic
- hosts: servers
roles:
- role: ansiblebit.oracle-java

# debian + debian/ubuntu | Java 10
- hosts: servers
roles:
- role: ansiblebit.oracle-java

# debian + debian/ubuntu | Java 8
- hosts: servers
roles:
- role: ansiblebit.oracle-java
oracle_java_apt_repository: "ppa:webupd8team/java"

# debian | custom | Java 10
- hosts: servers
roles:
- role: ansiblebit.oracle-java
oracle_java_apt_repository: 'deb http://ppa.launchpad.net/linuxuprising/java/ubuntu bionic main'

# debian | custom | Java 8
- hosts: servers
roles:
- role: ansiblebit.oracle-java
oracle_java_apt_repository: 'deb http://ppa.launchpad.net/webupd8team/java/ubuntu bionic main'
```
Use `--skip-tags=debug` if you want to suppress debug information.

## Test

```bash
tox -e py27-ansible26 -- --box centos7-64.vagrant.dev
tox -e py27-ansible26 -- --box bionic64.vagrant.dev
# manual
source .tox/py27-ansible26/bin/activate
cd tests
vagrant up bionic64.vagrant.dev
bash test_idempotence.sh \
--box bionic64.vagrant.dev \
--inventory .vagrant/provisioners/ansible/inventory/vagrant_ansible_inventory
## look at idempotence test logs
less log/bionic64.vagrant.dev_idempotence_py27-ansible26.log
## debug
vagrant ssh bionic64.vagrant.dev
bash test_checkmode.sh \
--box bionic64.vagrant.dev \
--inventory .vagrant/provisioners/ansible/inventory/vagrant_ansible_inventory
## look at checkmode test logs
less log/bionic64.vagrant.dev_checkmode_py27-ansible26.log
vagrant destroy bionic64.vagrant.dev
```

## Links

- [launchpad > WebUpd8 > Oracle Java (JDK) 8 / 9 Installer PPA](https://launchpad.net/~webupd8team/+archive/ubuntu/java)
- [launchpad > Linux Uprising > Oracle Java](https://launchpad.net/~linuxuprising/+archive/ubuntu/java)
4 changes: 2 additions & 2 deletions defaults/darwin-macosx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@

oracle_java_dir_source: "{{ ansible_env.HOME }}/Downloads"
oracle_java_dmg_filename: ""
oracle_java_dmg_url: "/{{ oracle_java_dmg_filename }}"

oracle_java_os_supported: no

oracle_java_dmg_url: "/{{ oracle_java_dmg_filename }}"
13 changes: 13 additions & 0 deletions defaults/debian-ubuntu.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
# file: oracle-java/defaults/debian-ubuntu.yml
#
# Default variables for Ubuntu Linux distributions.
#

oracle_java_apt_repository: "ppa:linuxuprising/java"
oracle_java_cache_valid_time: 3600
oracle_java_deb_package: 'oracle-java10-installer'
oracle_java_debconf_package_default: 'oracle-java10-set-default'
oracle_java_home: "/usr/lib/jvm/java-10-oracle"
oracle_java_os_supported: yes
oracle_java_state: latest
9 changes: 5 additions & 4 deletions defaults/debian.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
# Default variables for Debian-based Linux distributions.
#

oracle_java_apt_repository: 'deb http://ppa.launchpad.net/linuxuprising/java/ubuntu bionic main'
oracle_java_apt_repository_key: 'EA8CACC073C3DB2A'
oracle_java_cache_valid_time: 3600

oracle_java_home: "/usr/lib/jvm/java-{{ oracle_java_version }}-oracle"

oracle_java_deb_package: 'oracle-java10-installer'
oracle_java_debconf_package_default: 'oracle-java10-set-default'
oracle_java_home: "/usr/lib/jvm/java-10-oracle"
oracle_java_os_supported: yes

oracle_java_state: latest
10 changes: 3 additions & 7 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,8 @@
# defaults file
#

oracle_java_dir_source: '/usr/local/src'
oracle_java_downloads:
10.0.2:
redhat: http://download.oracle.com/otn-pub/java/jdk/10.0.2+13/19aef61b38124481863b1413dce1855f/jdk-10.0.2_linux-x64_bin.rpm

oracle_java_set_as_default: yes

oracle_java_version: 8
oracle_java_version_string: "1.{{ oracle_java_version }}.0_{{ oracle_java_version_update }}"
oracle_java_ansible_arch_mappings:
x86_64: x64
i386: i586
11 changes: 7 additions & 4 deletions defaults/redhat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@
# Default variables for Redhat-based Linux distributions.
#

oracle_java_home: "/usr/java/jdk-{{ oracle_java_version }}"

oracle_java_dir_source: '/usr/local/src'
oracle_java_download_timeout: 60
oracle_java_rpm_filename: 'jdk-10.0.2_linux-x64_bin.rpm'
oracle_java_home: '/usr/java/default'
oracle_java_os_supported: yes
oracle_java_rpm_url: 'http://download.oracle.com/otn-pub/java/jdk/10.0.2+13/19aef61b38124481863b1413dce1855f/jdk-10.0.2_linux-x64_bin.rpm'
oracle_java_rpm_validate_certs: yes

oracle_java_download_timeout: 10
oracle_java_version: 10
oracle_java_version_string: 10.0.2
7 changes: 3 additions & 4 deletions tasks/check_environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@
oracle_java_installed={{ not oracle_java_task_installed.changed }}

- name: determine which Java version is installed
shell: java -version
when: oracle_java_installed
shell: java -version 2>&1 | head -n 1 | awk '{ print $3 }' | awk -F '"' '{ print $2 }'
register: oracle_java_task_version
when: oracle_java_installed
changed_when: False

- name: set fact oracle_java_installed_version
set_fact:
oracle_java_version_installed="{{ oracle_java_task_version.stderr.split('\n')[0]|regex_replace('.*\"(.*)\"','\\1') }}"
oracle_java_version_installed="{{ oracle_java_task_version.stdout }}"
when: oracle_java_task_version is defined and oracle_java_task_version.stdout is defined
changed_when: False

Expand All @@ -38,4 +38,3 @@
- oracle_java_task_installed
- oracle_java_task_version
- oracle_java_version_installed
- oracle_java_version_string
57 changes: 0 additions & 57 deletions tasks/debian/main.yml

This file was deleted.

4 changes: 3 additions & 1 deletion tasks/debug.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@
- oracle_java_home
- oracle_java_installed
- oracle_java_os_supported
- oracle_java_apt_repository
- oracle_java_apt_repository_key
- oracle_java_set_as_default
- oracle_java_state
- oracle_java_version_build
- oracle_java_version
- oracle_java_version_installed
- oracle_java_version_string
Loading

0 comments on commit 6f4d635

Please sign in to comment.