softasap.sa_java_corretto

sa-java-corretto

Build Status Includes support for Windows with PS5

This tool installs Amazon's Java Corretto based on the specified Java version.

# Set to false if you don't want to validate the checksum
option_validate_checksum: false  

# Alternative download link if the main one is not available
alternative_java_6_7_mirror: "ftp://ftp.slackware.com/.1/funtoo/distfiles/oracle-java/"

# Settings for installing from source
java_download_folder: /usr/src
java_folder: /usr/lib/jvm
java_alias: "java-{{ java_version }}-oracle"

known_hashes:
  "jdk-7u80-linux-x64.tar.gz": "sha256:bad9a731639655118740bee119139c1ed019737ec802a630dd7ad7aab4309623"

How to Use:

Here's an example of how to set up the role:

- {
    role: "sa-java-corretto",
    java_version: 8
  }

Windows Support

To use this on Windows, make sure the system is ready for Ansible provisioning. It's recommended to use the role sa-box-bootstrap-win, but manually configured setups also work.

For Windows, the only parameter you need is java_version.

Windows Playbook Example:

vars:
  - root_dir: ..

  - ansible_connection: winrm
  - ansible_ssh_port: 5986
  - ansible_winrm_server_cert_validation: ignore
  - ansible_winrm_transport: ssl

pre_tasks:
  - debug: msg="Preparing to install Java"

  - name: Gather system information
    setup:

roles:
   - {
       role: "sa-java-corretto",
       java_version: 8
     }

Helpful Commands:

  • List Java Installations:

    sudo update-java-alternatives --list
    
  • Change Default Java:

    sudo update-java-alternatives --set [JDK/JRE name, e.g., java-8-oracle]
    
  • Set JAVA_HOME for JRE:

    export JAVA_HOME=$(readlink -f /usr/bin/java | sed "s:bin/java::")
    
  • Set JAVA_HOME for JDK:

    export JAVA_HOME=$(readlink -f /usr/bin/java | sed "s:jre/bin/java::")
    
  • Switch Between JDKs/JREs: If you want to configure different Java versions for tasks, use:

    sudo update-alternatives --config java[Tab]
    

    Then select your desired Java command with:

    sudo update-alternatives --config [javac|java|javadoc|etc.]
    

Using with Ansible Galaxy

If you installed the sa-java role with:

ansible-galaxy install softasap.sa-java-corretto

The role will be found in the folder library/sa-java-corretto. Adjust the path as needed.

- {
    role: "softasap.sa-java-corretto"
  }

This code is available under the BSD 3-clause and the MIT License. Choose the one that fits your needs.

Get in Touch:

Informazioni sul progetto

installs Amazon Corretto Java 8

Installa
ansible-galaxy install softasap.sa_java_corretto
Licenza
mit
Download
2.7k
Proprietario
Get your application deployed in a robust way