idealista.java_role

Logo

Build Status Docker Hub pulls

Java Ansible Role

This Ansible Role installs Java Development Kits (JDKs) from various providers (OpenJDK, AdoptOpenJDK, and Corretto) on a Debian/Ubuntu or CentOS system.

Getting Started

Follow these steps to use the role in your Ansible playbook.

When run, it will install Java using Debian or RHEL packages.

Requirements

To use this role in your playbook, ensure you have:

  • Ansible version 2.9.0 or higher.
  • Your target environment should be either Debian/Ubuntu or CentOS.

For testing, you will need Python 3.7+ and Pipenv.

Installation

Add the role to your dependency file (e.g., requirements.yml):

- src: http://github.com/idealista/java_role.git
  scm: git
  version: 7.0.0
  name: java

Or you can use Ansible Galaxy if you prefer:

- src: idealista.java_role
  version: 7.0.0
  name: java

You can also find Docker images for various Debian, Ubuntu, and CentOS versions available on Docker Hub.

Install the role with the Ansible Galaxy command:

$ ansible-galaxy install -p roles -r requirements.yml -f

Use the role in your playbook like this:

---
- hosts: someserver
  roles:
    - java

How to Use

Docker Hub

We publish every version of the role as a Docker image on Docker Hub: https://hub.docker.com/r/idealista/jdk.

You can pull our images by running:

docker pull idealista/jdk:${JDK_VERSION}-${DOCKER_IMAGE_BASE}-${JDK_VENDOR}headless

Where:

  • JDK_VERSION: The version of JDK you want.
  • DOCKER_IMAGE_BASE: Choose from stretch, buster, xenial, bionic, focal, 7, or 8.
  • JDK_VENDOR: Options are openjdk, adoptopenjdk, or corretto.

For example:

docker pull idealista/jdk:8u191-xenial-openjdk-headless

You can find a list of available tags here.

Ansible

Edit the defaults/main.yml file.

OpenJDK

Select a specific OpenJDK version by setting the java_open_jdk_version_major variable. Here are the major releases by operating system:

Operating System OpenJDK Major Release
Debian Stretch 8 (default)
Debian Buster 11 (default)
Debian Bullseye 17
Ubuntu Xenial 8, 9 (default)
Ubuntu Bionic 8, 11 (default)
Ubuntu Focal 8, 11, 17 (default)
CentOS 7 11 (default)
CentOS 8 11 (default)

Other OpenJDK versions from different Linux distributions are not officially supported, but you can still use this role by adding extra repositories, as noted in the respective directories.

Adding Certificates to Java's Truststore

This role allows you to add certificates to Java's truststore. The location of the truststore may vary by Java version:

  • For Java 9 and later: $JAVA_HOME/lib/security/cacerts
  • For Java before version 9: $JAVA_HOME/jre/lib/security/cacerts

You can specify the truststore location by changing the java_keystore_dir variable. You will also need to set java_certs for the certificates you wish to add and java_cert_keystore_pass for the truststore password.

Testing the Role

$ pipenv sync
$ DOCKER_IMAGE_BASE=(debian:stretch-slim|debian:buster-slim|debian_bullseye-slim|ubuntu:xenial|ubuntu:bionic|ubuntu:focal|centos:7|centos:8)
JDK_VENDOR=(openjdk|adoptopenjdk|corretto)
JDK_MAJOR=(use valid major version)
JDK_VERSION=(use valid version)
pipenv run molecule test

Note: If JDK_VENDOR is not specified, the role defaults to openjdk. If JDK_VERSION is not specified, the latest version will be installed for the selected major release. By default, Debian Stretch will be used if no distribution is specified.

Check the molecule directory for possible testing platforms.

Built With

Ansible Molecule Packer

Version Information

To see available versions, check the tags on this repository. You can view changes for each version in the CHANGELOG.md file.

Authors

See the list of contributors who have worked on this project.

License

Apache 2.0 License

This project is licensed under the Apache 2.0 license - see the LICENSE file for details.

Contributing

For details on contributing, please review CONTRIBUTING.md for our code of conduct and submission process for pull requests.

Informazioni sul progetto

Java role, installs JDKs from different vendors (OpenJDK, AdoptOpenJDK and Corretto) and sets system defaults

Installa
ansible-galaxy install idealista.java_role
Licenza
apache-2.0
Download
58.1k
Proprietario
We release serious projects apart from Ansible Roles.