gilcot.ojdk

Open Java Development Kit

This role is for managing the Open Java Development Kit (OpenJDK) on most operating systems (OS).

OpenJDK is a free and open-source version of the Java Platform, Standard Edition (J2SE) as defined by the Java Community Process (JCP). It is licensed under the GNU General Public License version 2 with linking exception and includes the HotSpot virtual machine (JVM) and javac (the official Java compiler from Sun).

OpenJDK serves as a reference implementation, meaning it provides a standard version that other implementations can build upon. However, it has some minor differences from Oracle JDK and varies in its release model and paid support options.

Table of Contents:

Starting

This section covers the initial setup to get this role functioning.

Requirements

This role does not depend on any other roles.

It uses the native package manager of the distribution and configured repositories.

The role works on distributions that have builds available (for a detailed list, see https://wiki.openjdk.java.net/display/Build/Supported+Build+Platforms). Also, the available versions might differ based on your distribution's major release.

v6 v7 v8 v9 v10 v11 v12 distribution release
7 8 Alpine versions 3.3 to 3.9
7 8 9 Alpine edge
1.6.0 1.7.0 1.8.0 ALT Linux Sisyphus
7 8 10 Arch Linux
1.6.0 1.7.0 1.8.0 CentOS 6
1.6.0 1.7.0 1.8.0 11 CentOS 7
6 7 Debian 7 (Wheezy)
7 Debian 8 (Jessie)
8 Debian 9 (Stretch)
8 11 Debian 10 (Buster)
8 11 12 Debian Sid
1.8.0 9 11 ... Fedora 27 / 28
1.8.0 ... 11 ... Fedora 29 / Rawhide
(port) (+port) 8 (+port) FreeBSD 10
(port) (+port) 8 (+port) 11 FreeBSD 11 / 12
1.7.0 Mageia 4.1
1.8.0 Mageia 5.1 / 6.1 / Caudron
7 8 NetBSD 7.0 / 7.1 / 7.2
8 NetBSD 8.0
1.7.0 1.8.0 9 10 11 12 OpenMandriva Cooker
1.6.0 1.7.0 OpenMandriva Lx 2013.0
1.6.0 1.7.0 1.8.0 OpenMandriva Lx 2014.2
1.7.0 1.8.0 OpenMandriva Lx 3.0
1_8_0 10 11 openSUSE Leap 15.0
1_7_0 1_8_0 openSUSE Leap 42.3
1_8_0 9 10 11 openSUSE Tumbleweed
1.6.0 ROSA 2012.1 / Enterprise Desktop
1.7.0 ROSA 2014.1
1.8.0 ROSA 2016.1
(7-)7 8 Slackware 14.1/14.0/13.37/Current
6-6 (7-)7 (8-)8 9-9 Slackware 14.2
6 7 Ubuntu 14.04 LTS (Trusty Thar)
8 9 Ubuntu 16.04 LTS (Xenial Xerus)
8 11 Ubuntu 18.04 LTS (Bionic Beaver) / 18.10 (Cosmic Cuttlefish)

Installing

To install this role, add the following lines to your roles dependency file:

- src: http://github.com/gilcot/ansible-ojdk.git
  scm: git
  version: 1.0.0
  name: openjdk
- src: gilcot.openjdk
  version: 1.0.0
  name: openjdk

Then, use this file to install the role on your control host by running:

# Replace $roles with the path to your roles folder if it's not the default
# Replace $specs with the requirements file you created earlier
# The last option forces the install, useful for version changes
ansible-galaxy install -p $roles -r $specs -f

Using

This section explains how to integrate the role into your playbooks.

Variables

This role uses only a few variables:

ojdk_version

This is the version of the JDK to install.
Be careful! This is not the package version or the number in the package's name! See the table above.
This value is required and must be a number.

ojdk_state

This defines the desired state and is required. It can be:

  • present to install the package if it is not already installed,
  • absent to remove the package if it is there,
  • any other value accepted by the module (for example, latest to upgrade to the latest version).

ojdk_gpg_uncheck

This is a boolean (no/false or yes/true) used with some package managers to skip checking for signatures/certificates. Disabling this check can be useful in rare cases.

ojdk_repository

This variable is used by some package managers to specify an additional repository. The format (URL or path) and meaning depends on the OS.

distribution mandatory used for
AIX path with AIX packages (required for installation)
Debian based URL to a different repository where the desired OpenJDK version can be found
FreeBSD change the default source directory for packages
HP-UX the repository from which to install or upgrade the package
Mac OSX the absolute path to the package file
OpenBSD change the default source directory for packages
Red Hat based URL to a different repository for the OpenJDK version
Solaris location to install the package from (must be a valid path for pkgadd or a valid repository path defined in /etc/opt/csw/pkgutil.conf)
Windows either the absolute path to the package file or a URL to a Chocolatey feed or a folder containing .nupkg files

For some distributions like CentOS and Ubuntu, it might be useful to add the repository (either manually or in a previous task) before using this role. Adding this parameter ensures basic setup.

Conditions

The role modifies package installations, so it requires elevated privileges. Make sure to call the role accordingly.

It also uses facts about the OS family and distribution (name and version). You can either allow fact gathering or provide this information manually.

Examples

Now you are ready to use this role in your playbooks.
Remember that these actions should be performed as a root user (that's why we use privilege escalation in the examples).

To install (default state) JDK 12 on a group named servlets:

- hosts: servlets
  become: yes
  gather_facts: yes
  roles:
    - { role: openjdk, ojdk_version: 12 }

To remove JDK5 (for demonstration purposes, as this doesn't exist) on a test host:

- hosts: dummy
  become: yes
  gather_facts: yes
  roles:
    - { role: openjdk, ojdk_version: 5, ojdk_state: absent }

(The same, using standard YAML syntax)

- hosts: dummy
  become: yes
  gather_facts: yes
  roles:
    - role: openjdk
      ojdk_version: 5
      ojdk_state: absent

If your control master’s inventory looks like this:

[dummies]
dummy

[olders]
foo
bar

[newers]
baz
qix

[servlets:children]
olders
newers

[dummies:vars]
ojdk_version = 5
ojdk_state = absent

[olders:vars]
ojdk_version = 8

[newers:vars]
ojdk_version = 11

[servlets:vars]
ojdk_state = present

Then your playbook simply becomes:

- hosts: dummy
  become: yes
  roles:
    - openjdk

Misc

Build Status

License

This role is licensed under the GNU GPLv3 (see the LICENSE file for details).

Authors

gilcot advocates for Free Software and uses Ansible for deployments.

Contribution

  • Rate this role on Ansible Galaxy
  • Report any issues to help improve it
  • Request to merge code
  • Thank the authors with:
Informazioni sul progetto

Ansible role to manage OpenJDK package

Installa
ansible-galaxy install gilcot.ojdk
Licenza
gpl-3.0
Download
111
Proprietario