sdkman_init

Ansible Role: SDKMAN init

Tests Ansible Galaxy License

Role to initialize SDKMAN the software development kit manager. This role allows you to install particular SDKs as part of your Ansible provisioning and set which versions should be use by default.

Important: this role requires SDKMAN to be already installed. You can use our gantsign.sdkman role to install SDKMAN.

Requirements

  • Ansible >= 2.9

  • Linux Distribution

    • Debian Family

      • Debian

        • Stretch (9)
        • Buster (10)
        • Bullseye (11)
      • Ubuntu

        • Bionic (18.04)
        • Focal (20.04)
    • RedHat Family

      • Rocky Linux

        • 8
      • Fedora

        • 35
    • SUSE Family

      • openSUSE

        • 15.3
    • Note: other versions are likely to work but have not been tested.

Role Variables

The following variables will change the behavior of this role:

# SDKMAN is initialized per user so you must specify at least one user
users:
  - username: # User to initialize SDKMAN for
    sdkman_install:
      - candidate: # Candidate SDK name e.g. java
        version: # Candidate version to install
        path: # Optional. To add an existing SDK install to SDKMAN.
              # The `version` for the existing SDK can't be the same any of
              # those provided by SDKMAN. The version string is just an
              # identifier so you can give it any value you like (as long as it
              # doesn't clash with any other versions for this candidate).
    sdkman_default:
      _candidate_sdk_name_here_: # Optional. Default version

Example Playbooks

This is an example configuration for this role by itself (without the necessary role for installing SDKMAN).

- hosts: servers
  roles:
    - role: gantsign.sdkman_init
      users:
        - username: example_username
          sdkman_install:
            - candidate: java
              version: '8.0.181-zulu'
            - candidate: java
              version: '10'
              path: '/opt/java/jdk-10.0.2'
            - candidate: maven
              version: '3.5.4'
          sdkman_default:
            java: '10'
            maven: '3.5.4'

This is a complete example that uses the gantsign.sdkman role to install SDKMAN. Notice how the gantsign.sdkman_init role can be used more than once with Ansible tags to conditionally install particular SDKs.

- hosts: servers
  roles:
    - role: gantsign.sdkman
      sdkman_users:
        - example_username

    - role: gantsign.sdkman_init
      tags:
        - java
      users:
        - username: example_username
          sdkman_install:
            - candidate: java
              version: '8.0.181-zulu'
            - candidate: java
              version: '10'
              path: '/opt/java/jdk-10.0.2'
          sdkman_default:
            java: '10'

    - role: gantsign.sdkman_init
      tags:
        - java
        - maven
      users:
        - username: example_username
          sdkman_install:
            - candidate: maven
              version: '3.5.4'
          sdkman_default:
            maven: '3.5.4'

More Roles From GantSign

You can find more roles from GantSign on Ansible Galaxy.

Development & Testing

This project uses Molecule to aid in the development and testing; the role is unit tested using Testinfra and pytest.

To develop or test you'll need to have installed the following:

Because the above can be tricky to install, this project includes Molecule Wrapper. Molecule Wrapper is a shell script that installs Molecule and it's dependencies (apart from Linux) and then executes Molecule with the command you pass it.

To test this role using Molecule Wrapper run the following command from the project root:

./moleculew test

Note: some of the dependencies need sudo permission to install.

License

Apache 2

Author Information

John Freeman

GantSign Ltd. Company No. 06109112 (registered in England)

About

Ansible role for initializing the SDKMAN software development kit manager.

Install
ansible-galaxy install gantsign/ansible_role_sdkman_init
GitHub repository
License
apache-2.0
Downloads
3880