Getting started
Sections
Support for backported Java versions
The role will install OpenJDK 8 environment on Debian Jessie by default, using
the backported packages from the jessie-backports repository. Backports are
configured using debops.apt Ansible role; if the debops.java does not
detect the debops.apt configuration, it will switch to the default JRE
packages available for a given release. Remember to use the provided example
playbook, which will configure APT preferences for the ca-certificates-java
package.
Support for Oracle Java packages
To use the non-free Oracle Java packages, check the JavaPackage
page on Debian Wiki to see how to build the proper APT packages with non-free
Java. You will need to publish them in a local APT repository. After that, you
can change the default Java package in java__base_packages list to your
preferred version.
Support for Eclipse Temurin
Eclipse Temurin (Adoptium) is an open-source Java distribution maintained by the Eclipse Foundation. It is based on the OpenJDK class libraries and is licensed under the GPLv2 with the Classpath Exception, making it suitable for redistribution in commercial products. Temurin provides binary builds for multiple platforms and Java versions that are not always available in the official Debian repositories, such as Java 8 on Debian Bookworm and later.
To use Eclipse Temurin instead of the default OpenJDK packages, set in your Ansible inventory:
java__flavor: 'temurin'
The extrepo role is used to enable the official
Adoptium APT repository before the
Temurin packages are installed. Ensure that the service playbook includes the
extrepo role before java.
When you use this flavor, the java__temurin_version variable is set
automatically based on the Debian release (for example, version 21 on
Trixie, 17 on Bookworm). You can override it to pin a specific version:
# For Elasticsearch 6.x compatibility
java__temurin_version: '8'
Conditional installation of Java Development Kit (JDK)
Some environments might require a full Java Development Kit to work correctly,
however by default the debops.java role installs only the Java Runtime
Environment (JRE). To install the full JDK in a compatible version, you can set
the java__install_jdk boolean variable to True, either via
Ansible inventory variables or via role dependent variables.
Example inventory
To configure a Java environment on a specific host, it needs to be added to the
[debops_service_java] host group in Ansible inventory:
[debops_service_java]
hostname
Example playbook
If you are using this role without DebOps, here's an example Ansible playbook
that uses the debops.java role:
---
- name: Manage Java environment
collections: [ 'debops.debops' ]
hosts: [ 'debops_service_java' ]
become: True
environment: '{{ inventory__environment | d({})
| combine(inventory__group_environment | d({}))
| combine(inventory__host_environment | d({})) }}'
roles:
- role: extrepo
tags: [ 'role::extrepo', 'skip::extrepo', 'role::java' ]
extrepo__dependent_sources:
- '{{ java__extrepo__dependent_sources }}'
- role: java
tags: [ 'role::java', 'skip::java' ]