Giter Club home page Giter Club logo

ansible-role-java's Introduction

Install and configure java on your system.

GitHub GitLab Downloads Version
github gitlab downloads Version

This example is taken from molecule/default/converge.yml and is tested on each push, pull request and release.

---
- name: Converge
  hosts: all
  become: true
  gather_facts: true

  roles:
    - role: robertdebock.java
# To install Oracle java 21 package:
# NOTE: Please download Java yourself, place it in `files/`.
# This is to avoid licensing issues.
# java_source: local
# java_type: jdk
# java_format: deb
# java_version: 21

The machine needs to be prepared. In CI this is done using molecule/default/prepare.yml:

---
- name: Prepare
  hosts: all
  become: true
  gather_facts: false

  roles:
    - role: robertdebock.bootstrap

Also see a full explanation and example on how to use these roles.

The 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.
# By default, a distribution default is used, mapped in `vars/main.yml`.
# By setting java_version, you overwrite this default to your selected
# version.
java_version: "{{ java_default_version }}"

# Set the format of the installation source, valid values are "deb", "rpm" or "targz".
# This is only valid with "java_vendor == oracle"
java_format: targz

# Where do the RPMs come from when installing Oracle RPMs?
# Either "local" or "repository".
# Valid for "java_vendor == oracle" and "java_format" == "rpm"
java_source: local

# Choose if you can JCE installed. Only applicable for (both):
# - java_vendor == "oracle"
# - java_version == "8"
java_jce: true

# In case of "java_vendor == oracle" and "java_format == targz", a directory
# as to be set where to install.
java_install_directory: /opt

The following roles are used to prepare a system. You can prepare your system in another way.

Requirement GitHub GitLab
robertdebock.bootstrap Build Status GitHub Build Status GitLab

This role is a part of many compatible roles. Have a look at the documentation of these roles for further information.

Here is an overview of related roles: dependencies

This role has been tested on these container images:

container tags
Alpine all
Amazon Candidate
EL 8, 9
Debian all
Fedora all
opensuse all
Ubuntu all

The minimum version of Ansible required is 2.12, tests have been done to:

  • The previous version.
  • The current version.
  • The development version.

If you find issues, please register them in GitHub.

Apache-2.0.

robertdebock

Please consider sponsoring me.

ansible-role-java's People

Contributors

it-praktyk avatar robert-de-bock avatar robertdebock avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

ansible-role-java's Issues

JavaDoc

Add the option to install javadoc, please.

fix JAVA_HOME

One of the following PRs should be choosen:

  • #14
    when a shell script will be used to set variables. This will not set JAVA_HOME for every process and not for all shells.

  • #15
    set path to /etc/environment and fix assignment expression ( do not use export command in assignments expressions )

Oracle Java 10 is out

ISSUE TYPE
  • Feature Idea
SUMMARY

Oracle has released Java 10. Please modify the role to also allow Oracle Java 10. (jdk & jre)

`java_version` variable not used when installing an openjdk

Think the title says everything :). I had to set the variable java_default_version to install the appropriate version. If I'm correct the setting for the openjdk variable come from the file vars/main.yml

java_openjdk_package: "{{ _java_openjdk_package[java_type][java_default_version|int][ansible_distribution] | default(_java_openjdk_package[java_type][java_default_version|int]['default'] | default([] )) }}"

Sample Playbook

---
- name: Get some delicious coffee
  hosts: all
  become: true

  tasks:
    - name: Bootstrap machine
      include_role: 
        name: galaxy/robertdebock.bootstrap

    - name: Java must be present
      include_role: 
        name: galaxy/robertdebock.java
      vars:
        java_vendor: openjdk
        java_type: jdk
        java_version: "8"

Output

Taken from the target:

vagrant@ubuntu-focal:~$ java --version
openjdk 11.0.11 2021-04-20
OpenJDK Runtime Environment (build 11.0.11+9-Ubuntu-0ubuntu2.20.04)
OpenJDK 64-Bit Server VM (build 11.0.11+9-Ubuntu-0ubuntu2.20.04, mixed mode, sharing)

Environment

  • Control node OS: Manjaro Linux
  • Control node Ansible version: 2.11.1
  • Managed node OS: Ubuntu 20.04.3

JAVA_HOME

Is your feature request related to a problem? Please describe.
JAVA_HOME is not set after this role ran.

Describe the solution you'd like
The role should set JAVA_HOME.

Describe alternatives you've considered
Set JAVA_HOME myself.

Additional context
Do you have any thoughts? I could work on a PR, if it helps.

multiple JDKs

Is your feature request related to a problem? Please describe.
I need to migrate to newer Java.

Describe the solution you'd like
I need java 8, 9 and maybe more.

Describe alternatives you've considered
geerlingguy

Additional context
The README should explain how to run the role multiple time with different vars.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.