robertdebock.java
Ansible Role: Java
This role helps you install and configure Java on your system easily.
GitHub | GitLab | Downloads | Version |
---|---|---|---|
Example Playbook
This example is from molecule/default/converge.yml
and gets tested whenever changes are made or releases are published.
---
- name: Converge
hosts: all
become: true
gather_facts: true
roles:
- role: robertdebock.java
# To install Oracle Java 21 package:
# NOTE: Please download Java yourself and put it in `files/`.
# This avoids licensing issues.
# java_source: local
# java_type: jdk
# java_format: deb
# java_version: 21
You'll need to prepare the machine. In Continuous Integration (CI), this is done using molecule/default/prepare.yml
:
---
- name: Prepare
hosts: all
become: true
gather_facts: false
roles:
- role: robertdebock.bootstrap
For a detailed guide on how to use these roles, check out this link.
Role Variables
Default values for the variables are set in defaults/main.yml
:
---
# defaults file for java
# Set the vendor of java, valid values are "openjdk" and "oracle".
java_vendor: openjdk
# Set the variable to install the type, valid values are "jre" and "jdk".
java_type: jre
# Set the version of java, valid values are 6, 7, 8, 9, 10, 11, 12, 13, 17, 19, 20, or 21.
# The default version is used unless overridden by java_version.
java_version: "{{ java_default_version }}"
# Set the format of the installation source, valid values are "deb", "rpm", or "targz".
# This only applies if java_vendor is "oracle".
java_format: targz
# Source for RPMs when installing Oracle RPMs?
# Either "local" or "repository".
# Applies when java_vendor is "oracle" and java_format is "rpm".
java_source: local
# Choose if you want JCE installed. Only applicable for:
# - java_vendor == "oracle"
# - java_version == "8"
java_jce: true
# For "java_vendor == oracle" and "java_format == targz", specify the directory for installation.
java_install_directory: /opt
Requirements
- You need the pip packages listed in requirements.txt.
State of Used Roles
The following roles are used to prepare the system. You can use a different method if you prefer.
Requirement | GitHub | GitLab |
---|---|---|
robertdebock.bootstrap |
Context
This role is part of many compatible roles. You can find more information in the documentation for these roles.
Compatibility
This role has been tested on the following container images:
Container | Tags |
---|---|
Alpine | all |
Amazon | Candidate |
EL | 9 |
Debian | all |
Fedora | all |
Ubuntu | all |
Minimum Ansible version required is 2.12. Testing has been performed on:
- The previous version.
- The latest version.
- The development version.
If you encounter any issues, please report them on GitHub.
License
This role is licensed under the Apache-2.0.
Author Information
This role was created by robertdebock.
Consider sponsoring me.
Install and configure java on your system.
ansible-galaxy install robertdebock.java