├── .ansible-lint ├── .github ├── FUNDING.yml ├── ISSUE_TEMPLATE │ ├── bug_report.md │ └── feature_request.md ├── pull_request_template.md ├── settings.yml └── workflows │ ├── galaxy.yml │ ├── molecule.yml │ ├── requirements2png.yml │ └── todo.yml ├── .gitignore ├── .gitlab-ci.yml ├── .pre-commit-config.yaml ├── .yamllint ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── SECURITY.md ├── defaults └── main.yml ├── meta ├── main.yml └── preferences.yml ├── molecule └── default │ ├── converge.yml │ ├── molecule.yml │ ├── prepare.yml │ └── verify.yml ├── requirements.txt ├── requirements.yml ├── tasks ├── assert.yml └── main.yml ├── tox.ini └── vars └── main.yml /.ansible-lint: -------------------------------------------------------------------------------- 1 | --- 2 | # 3 | # Ansible managed 4 | # 5 | exclude_paths: 6 | - meta/preferences.yml 7 | - molecule/default/prepare.yml 8 | - molecule/default/converge.yml 9 | - molecule/default/verify.yml 10 | - molecule/default/collections.yml 11 | - .tox 12 | - .cache 13 | - .github 14 | - requirements.yml 15 | 16 | enable_list: 17 | - name[prefix] 18 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | --- 2 | github: robertdebock 3 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help me improve 4 | 5 | --- 6 | 7 | # Describe the bug 8 | 9 | A clear and concise description of what the bug is. 10 | 11 | ## Playbook 12 | 13 | Please paste the playbook you are using. (Consider `requirements.yml` and 14 | optionally the command you've invoked.) 15 | 16 | ```yaml 17 | --- 18 | YOUR PLAYBOOK HERE 19 | ``` 20 | 21 | ## Output 22 | 23 | Show at least the error, possible related output, maybe just all the output. 24 | 25 | ## Environment 26 | 27 | - Control node OS: [e.g. Debian 9] (`cat /etc/os-release`) 28 | - Control node Ansible version: [e.g. 2.9.1] (`ansible --version`) 29 | - Managed node OS: [e.g. CentOS 7] (`cat /etc/os-release`) 30 | 31 | Please consider [sponsoring me](https://github.com/sponsors/robertdebock). 32 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | 5 | --- 6 | 7 | # Proposed feature 8 | 9 | A clear and concise description of what you want to happen. 10 | 11 | ## Rationale 12 | 13 | Why is this feature required? 14 | 15 | ## Additional context 16 | 17 | Add any other context about the feature request here. 18 | 19 | Please consider [sponsoring me](https://github.com/sponsors/robertdebock). 20 | -------------------------------------------------------------------------------- /.github/pull_request_template.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Pull request 3 | about: Describe the proposed change 4 | 5 | --- 6 | 7 | **Describe the change** 8 | A clear and concise description of what the pull request is. 9 | 10 | **Testing** 11 | In case a feature was added, how were tests performed? 12 | -------------------------------------------------------------------------------- /.github/settings.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # 3 | # Ansible managed 4 | # 5 | repository: 6 | description: Install and configure java on your system. 7 | homepage: https://robertdebock.nl/ 8 | topics: java, oracle, openjdk, jre, jdk, alternatives, system, ansible, molecule, tox, playbook 9 | -------------------------------------------------------------------------------- /.github/workflows/galaxy.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # 3 | # Ansible managed 4 | # 5 | 6 | name: Release to Ansible Galaxy 7 | 8 | on: 9 | release: 10 | types: [created, edited, published, released] 11 | jobs: 12 | release: 13 | runs-on: ubuntu-latest 14 | steps: 15 | - name: galaxy 16 | uses: robertdebock/galaxy-action@1.2.1 17 | with: 18 | galaxy_api_key: ${{ secrets.galaxy_api_key }} 19 | -------------------------------------------------------------------------------- /.github/workflows/molecule.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # 3 | # Ansible managed 4 | # 5 | 6 | name: Ansible Molecule 7 | 8 | on: 9 | push: 10 | branches: 11 | - master 12 | pull_request: 13 | schedule: 14 | - cron: '19 10 10 * *' 15 | 16 | jobs: 17 | lint: 18 | runs-on: ubuntu-latest 19 | steps: 20 | - name: checkout 21 | uses: actions/checkout@v4 22 | - name: ansible-lint 23 | uses: ansible-community/ansible-lint-action@main 24 | 25 | molecule: 26 | needs: 27 | - lint 28 | runs-on: ubuntu-latest 29 | strategy: 30 | fail-fast: false 31 | matrix: 32 | distro: 33 | - image: "alpine" 34 | tag: "latest" 35 | - image: "amazonlinux" 36 | tag: "latest" 37 | - image: "enterpriselinux" 38 | tag: "latest" 39 | - image: "debian" 40 | tag: "latest" 41 | - image: "debian" 42 | tag: "bullseye" 43 | - image: "fedora" 44 | tag: "40" 45 | - image: "fedora" 46 | tag: "latest" 47 | - image: "ubuntu" 48 | tag: "latest" 49 | - image: "ubuntu" 50 | tag: "jammy" 51 | - image: "ubuntu" 52 | tag: "focal" 53 | steps: 54 | - name: checkout 55 | uses: actions/checkout@v4 56 | with: 57 | path: ansible-role-java 58 | 59 | - name: Set up Python 60 | uses: actions/setup-python@v5 61 | with: 62 | python-version: "3.13" 63 | 64 | - name: Configure Docker for systemd 65 | run: | 66 | sudo mkdir -p /etc/docker 67 | echo '{ 68 | "features": { 69 | "buildkit": true 70 | }, 71 | "exec-opts": ["native.cgroupdriver=systemd"] 72 | }' | sudo tee /etc/docker/daemon.json 73 | sudo systemctl restart docker || true 74 | 75 | - name: Install Docker 76 | uses: docker/setup-buildx-action@v3 77 | 78 | - name: Install dependencies 79 | run: | 80 | python -m pip install --upgrade pip 81 | pip install ansible-lint molecule molecule-plugins[docker] ansible-core 82 | if [ -f ansible-role-java/requirements.txt ]; then pip install -r ansible-role-java/requirements.txt; fi 83 | if [ -f ansible-role-java/requirements.yml ]; then ansible-galaxy install -r ansible-role-java/requirements.yml; fi 84 | 85 | # Create proper role directory structure for molecule 86 | mkdir -p ~/.ansible/roles 87 | ln -s ${GITHUB_WORKSPACE}/ansible-role-java ~/.ansible/roles/robertdebock.java 88 | 89 | - name: Test with molecule 90 | run: | 91 | cd ansible-role-java 92 | molecule test 93 | env: 94 | PY_COLORS: 1 95 | ANSIBLE_FORCE_COLOR: 1 96 | ANSIBLE_ROLES_PATH: ~/.ansible/roles:${GITHUB_WORKSPACE}/ansible-role-java 97 | image: ${{ matrix.distro.image }} 98 | tag: ${{ matrix.distro.tag }} 99 | -------------------------------------------------------------------------------- /.github/workflows/requirements2png.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # 3 | # Ansible managed 4 | # 5 | 6 | on: 7 | - push 8 | 9 | name: Ansible Graphviz 10 | 11 | jobs: 12 | build: 13 | runs-on: ubuntu-latest 14 | permissions: 15 | contents: write 16 | steps: 17 | - name: checkout 18 | uses: actions/checkout@v4 19 | with: 20 | path: ${{ github.repository }} 21 | - name: create png 22 | uses: robertdebock/graphviz-action@1.0.7 23 | - name: Commit files 24 | run: | 25 | cd ${{ github.repository }} 26 | git config --local user.email "github-actions[bot]@users.noreply.github.com" 27 | git config --local user.name "github-actions[bot]" 28 | git add requirements.dot requirements.png 29 | git commit -m "Add generated files" 30 | - name: save to png branch 31 | uses: ad-m/github-push-action@master 32 | with: 33 | directory: ${{ github.repository }} 34 | force: true 35 | branch: png 36 | -------------------------------------------------------------------------------- /.github/workflows/todo.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # 3 | # Ansible managed 4 | # 5 | 6 | name: "TODO 2 Issue" 7 | 8 | on: 9 | push: 10 | 11 | jobs: 12 | build: 13 | runs-on: "ubuntu-latest" 14 | steps: 15 | - uses: actions/checkout@v4 16 | - name: "TODO to Issue" 17 | uses: "alstr/todo-to-issue-action@v4" 18 | id: "todo" 19 | with: 20 | TOKEN: ${{ secrets.GITHUB_TOKEN }} 21 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .molecule 2 | *.log 3 | *.swp 4 | .tox 5 | .cache 6 | .DS_Store 7 | .ansible 8 | -------------------------------------------------------------------------------- /.gitlab-ci.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | variables: 4 | DEBIAN_FRONTEND: noninteractive 5 | 6 | molecule: 7 | image: python:3.13 8 | script: 9 | - apt-get update -qq 10 | - apt-get -y -qq install yamllint docker.io 11 | # Configure Docker for systemd 12 | - mkdir -p /etc/docker 13 | - echo '{"features":{"buildkit":true},"exec-opts":["native.cgroupdriver=systemd"]}' > /etc/docker/daemon.json 14 | - service docker restart || true 15 | # Install dependencies and run tests 16 | - pip install --no-cache-dir ansible-lint molecule molecule-plugins[docker] ansible-core 17 | - if [ -f requirements.txt ]; then pip install -r requirements.txt; fi 18 | - if [ -f requirements.yml ]; then ansible-galaxy install -r requirements.yml; fi 19 | # Create proper role directory structure for molecule 20 | - mkdir -p ~/.ansible/roles 21 | - ln -s $CI_PROJECT_DIR ~/.ansible/roles/robertdebock.java 22 | # Run molecule tests 23 | - cd $CI_PROJECT_DIR 24 | - ANSIBLE_ROLES_PATH=~/.ansible/roles:$CI_PROJECT_DIR molecule test 25 | rules: 26 | - if: $CI_COMMIT_REF_NAME == "master" 27 | parallel: 28 | matrix: 29 | - image: "alpine" 30 | tag: "latest" 31 | - image: "amazonlinux" 32 | tag: "latest" 33 | - image: "enterpriselinux" 34 | tag: "latest" 35 | - image: "debian" 36 | tag: "latest" 37 | - image: "debian" 38 | tag: "bullseye" 39 | - image: "fedora" 40 | tag: "40" 41 | - image: "fedora" 42 | tag: "latest" 43 | - image: "ubuntu" 44 | tag: "latest" 45 | - image: "ubuntu" 46 | tag: "jammy" 47 | - image: "ubuntu" 48 | tag: "focal" 49 | 50 | galaxy: 51 | image: python:3.13 52 | script: 53 | - apt-get update -qq 54 | - apt-get -y -qq install ansible-core 55 | - ansible-galaxy role import --api-key ${GALAXY_API_KEY} robertdebock ${CI_PROJECT_NAME} 56 | rules: 57 | - if: $CI_COMMIT_TAG != null 58 | -------------------------------------------------------------------------------- /.pre-commit-config.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | repos: 3 | - repo: https://github.com/pre-commit/pre-commit-hooks 4 | rev: v4.4.0 5 | hooks: 6 | - id: trailing-whitespace 7 | - id: end-of-file-fixer 8 | - id: check-added-large-files 9 | 10 | - repo: https://github.com/adrienverge/yamllint 11 | rev: v1.32.0 12 | hooks: 13 | - id: yamllint 14 | args: 15 | - -c=.yamllint 16 | 17 | - repo: https://github.com/robertdebock/pre-commit 18 | rev: v1.5.2 19 | hooks: 20 | - id: ansible_role_find_unused_variable 21 | - id: ansible_role_find_empty_files 22 | - id: ansible_role_find_empty_directories 23 | - id: ansible_role_find_undefined_handlers 24 | - id: ansible_role_find_unquoted_values 25 | - id: ansible_role_find_horizontal_when 26 | -------------------------------------------------------------------------------- /.yamllint: -------------------------------------------------------------------------------- 1 | --- 2 | extends: default 3 | 4 | rules: 5 | braces: 6 | max-spaces-inside: 1 7 | level: error 8 | brackets: 9 | max-spaces-inside: 1 10 | level: error 11 | line-length: disable 12 | truthy: 13 | check-keys: false 14 | 15 | ignore: | 16 | .tox/ 17 | .cache/ 18 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation. 6 | 7 | ## Our Standards 8 | 9 | Examples of behaviour that contributes to creating a positive environment include: 10 | 11 | * Using welcoming and inclusive language 12 | * Being respectful of differing viewpoints and experiences 13 | * Gracefully accepting constructive criticism 14 | * Focusing on what is best for the community 15 | * Showing empathy towards other community members 16 | 17 | Examples of unacceptable behaviour by participants include: 18 | 19 | * The use of sexualized language or imagery and unwelcome sexual attention or advances 20 | * Trolling, insulting/derogatory comments, and personal or political attacks 21 | * Public or private harassment 22 | * Publishing others' private information, such as a physical or electronic address, without explicit permission 23 | * Other conduct which could reasonably be considered inappropriate in a professional setting 24 | 25 | ## Our Responsibilities 26 | 27 | Project maintainers are responsible for clarifying the standards of acceptable behaviour and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behaviour. 28 | 29 | Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviours that they deem inappropriate, threatening, offensive, or harmful. 30 | 31 | ## Scope 32 | 33 | This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers. 34 | 35 | ## Enforcement 36 | 37 | Instances of abusive, harassing, or otherwise unacceptable behaviour may be reported by contacting the project team at robert@meinit.nl. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately. 38 | 39 | Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership. 40 | 41 | ## Attribution 42 | 43 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version] 44 | 45 | [homepage]: http://contributor-covenant.org 46 | [version]: http://contributor-covenant.org/version/1/4/ 47 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # [Please contribute](#please-contribute) 2 | 3 | You can really make a difference by: 4 | 5 | - [Making an issue](https://help.github.com/articles/creating-an-issue/). A well described issue helps a lot. (Have a look at the [known issues](https://github.com/search?q=user%3Arobertdebock+is%3Aissue+state%3Aopen).) 6 | - [Making a pull request](https://services.github.com/on-demand/github-cli/open-pull-request-github) when you see the error in code. 7 | 8 | I'll try to help and take every contribution seriously. 9 | 10 | It's a great opportunity for me to learn how you use the role and also an opportunity to get into the habit of contributing to open source software. 11 | 12 | ## [Step by step](#step-by-step) 13 | 14 | Here is how you can help, a lot of steps are related to GitHub, not specifically my roles. 15 | 16 | ### [1. Make an issue.](#1-make-an-issue) 17 | 18 | When you spot an issue, [create an issue](https://github.com/robertdebock/ansible-role-java/issues). 19 | 20 | Making the issue help me and others to find similar problems in the future. 21 | 22 | ### [2. Fork the project.](#2-fork-the-project) 23 | 24 | On the top right side of [the repository on GitHub](https://github.com/robertdebock/ansible-role-java), click `fork`. This copies everything to your GitHub namespace. 25 | 26 | ### [3. Make the changes](#3-make-the-changes) 27 | 28 | In you own GitHub namespace, make the required changes. 29 | 30 | I typically do that by cloning the repository (in your namespace) locally: 31 | 32 | ```shell 33 | git clone git@github.com:YOURNAMESPACE/ansible-role-java.git 34 | ``` 35 | 36 | Now you can start to edit on your laptop. 37 | 38 | ### [4. Optionally: test your changes](#4-optionally-test-your-changes) 39 | 40 | Install [molecule](https://molecule.readthedocs.io/en/stable/) and [Tox](https://tox.readthedocs.io/): 41 | 42 | ```shell 43 | pip install molecule tox ansible-lint docker 44 | ``` 45 | 46 | And run `molecule test`. If you want to test a specific distribution, set `image` and optionally `tag`: 47 | 48 | ```shell 49 | image=centos tag=7 molecule test 50 | ``` 51 | 52 | Once it start to work, you can test multiple version of Ansible: 53 | 54 | ```shell 55 | image=centos tag=7 tox 56 | ``` 57 | 58 | ### [5. Optionally: Regenerate all dynamic content](#5-optionally-regenerate-all-dynamic-content) 59 | 60 | You can use [Ansible Generator](https://github.com/robertdebock/ansible-generator) to regenerate all dynamic content. 61 | 62 | If you don't do it, I'll do it later for you. 63 | 64 | ### [6. Make a pull request](#6-make-a-pull-request) 65 | 66 | [GitHub](https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/creating-a-pull-request-from-a-fork) on pull requests. 67 | 68 | In the comment-box, you can [refer to the issue number](https://help.github.com/en/github/writing-on-github/autolinked-references-and-urls) by using #123, where 123 is the issue number. 69 | 70 | ### [7. Wait](#7-wait) 71 | 72 | Now I'll get a message that you've added some code. Thank you, really. 73 | 74 | CI starts to test your changes. You can follow the progress on Travis. 75 | 76 | Please consider [sponsoring me](https://github.com/sponsors/robertdebock). 77 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | APPENDIX: How to apply the Apache License to your work. 180 | 181 | To apply the Apache License to your work, attach the following 182 | boilerplate notice, with the fields enclosed by brackets "[]" 183 | replaced with your own identifying information. (Don't include 184 | the brackets!) The text should be enclosed in the appropriate 185 | comment syntax for the file format. We also recommend that a 186 | file or class name and description of purpose be included on the 187 | same "printed page" as the copyright notice for easier 188 | identification within third-party archives. 189 | 190 | Copyright 2025 Robert de Bock (robert@meinit.nl) 191 | 192 | Licensed under the Apache License, Version 2.0 (the "License"); 193 | you may not use this file except in compliance with the License. 194 | You may obtain a copy of the License at 195 | 196 | http://www.apache.org/licenses/LICENSE-2.0 197 | 198 | Unless required by applicable law or agreed to in writing, software 199 | distributed under the License is distributed on an "AS IS" BASIS, 200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 201 | See the License for the specific language governing permissions and 202 | limitations under the License. 203 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # [Ansible role java](#java) 2 | 3 | Install and configure java on your system. 4 | 5 | |GitHub|GitLab|Downloads|Version| 6 | |------|------|---------|-------| 7 | |[![github](https://github.com/robertdebock/ansible-role-java/workflows/Ansible%20Molecule/badge.svg)](https://github.com/robertdebock/ansible-role-java/actions)|[![gitlab](https://gitlab.com/robertdebock-iac/ansible-role-java/badges/master/pipeline.svg)](https://gitlab.com/robertdebock-iac/ansible-role-java)|[![downloads](https://img.shields.io/ansible/role/d/robertdebock/java)](https://galaxy.ansible.com/robertdebock/java)|[![Version](https://img.shields.io/github/release/robertdebock/ansible-role-java.svg)](https://github.com/robertdebock/ansible-role-java/releases/)| 8 | 9 | ## [Example Playbook](#example-playbook) 10 | 11 | This example is taken from [`molecule/default/converge.yml`](https://github.com/robertdebock/ansible-role-java/blob/master/molecule/default/converge.yml) and is tested on each push, pull request and release. 12 | 13 | ```yaml 14 | --- 15 | - name: Converge 16 | hosts: all 17 | become: true 18 | gather_facts: true 19 | 20 | roles: 21 | - role: robertdebock.java 22 | # To install Oracle java 21 package: 23 | # NOTE: Please download Java yourself, place it in `files/`. 24 | # This is to avoid licensing issues. 25 | # java_source: local 26 | # java_type: jdk 27 | # java_format: deb 28 | # java_version: 21 29 | ``` 30 | 31 | The machine needs to be prepared. In CI this is done using [`molecule/default/prepare.yml`](https://github.com/robertdebock/ansible-role-java/blob/master/molecule/default/prepare.yml): 32 | 33 | ```yaml 34 | --- 35 | - name: Prepare 36 | hosts: all 37 | become: true 38 | gather_facts: false 39 | 40 | roles: 41 | - role: robertdebock.bootstrap 42 | ``` 43 | 44 | Also see a [full explanation and example](https://robertdebock.nl/how-to-use-these-roles.html) on how to use these roles. 45 | 46 | ## [Role Variables](#role-variables) 47 | 48 | The default values for the variables are set in [`defaults/main.yml`](https://github.com/robertdebock/ansible-role-java/blob/master/defaults/main.yml): 49 | 50 | ```yaml 51 | --- 52 | # defaults file for java 53 | 54 | # Set the vendor of java, valid values are "openjdk" and "oracle". 55 | java_vendor: openjdk 56 | 57 | # Set the variable to install the type, valid values are "jre" and "jdk". 58 | java_type: jre 59 | 60 | # Set the version of java, valid values are 6, 7, 8, 9, 10, 11, 12, 13 17, 19, 20 or 21. 61 | # By default, a distribution default is used, mapped in `vars/main.yml`. 62 | # By setting java_version, you overwrite this default to your selected 63 | # version. 64 | java_version: "{{ java_default_version }}" 65 | 66 | # Set the format of the installation source, valid values are "deb", "rpm" or "targz". 67 | # This is only valid with "java_vendor == oracle" 68 | java_format: targz 69 | 70 | # Where do the RPMs come from when installing Oracle RPMs? 71 | # Either "local" or "repository". 72 | # Valid for "java_vendor == oracle" and "java_format" == "rpm" 73 | java_source: local 74 | 75 | # Choose if you can JCE installed. Only applicable for (both): 76 | # - java_vendor == "oracle" 77 | # - java_version == "8" 78 | java_jce: true 79 | 80 | # In case of "java_vendor == oracle" and "java_format == targz", a directory 81 | # as to be set where to install. 82 | java_install_directory: /opt 83 | ``` 84 | 85 | ## [Requirements](#requirements) 86 | 87 | - pip packages listed in [requirements.txt](https://github.com/robertdebock/ansible-role-java/blob/master/requirements.txt). 88 | 89 | ## [State of used roles](#state-of-used-roles) 90 | 91 | The following roles are used to prepare a system. You can prepare your system in another way. 92 | 93 | | Requirement | GitHub | GitLab | 94 | |-------------|--------|--------| 95 | |[robertdebock.bootstrap](https://galaxy.ansible.com/robertdebock/bootstrap)|[![Build Status GitHub](https://github.com/robertdebock/ansible-role-bootstrap/workflows/Ansible%20Molecule/badge.svg)](https://github.com/robertdebock/ansible-role-bootstrap/actions)|[![Build Status GitLab](https://gitlab.com/robertdebock-iac/ansible-role-bootstrap/badges/master/pipeline.svg)](https://gitlab.com/robertdebock-iac/ansible-role-bootstrap)| 96 | 97 | ## [Context](#context) 98 | 99 | This role is a part of many compatible roles. Have a look at [the documentation of these roles](https://robertdebock.nl/) for further information. 100 | 101 | Here is an overview of related roles: 102 | ![dependencies](https://raw.githubusercontent.com/robertdebock/ansible-role-java/png/requirements.png "Dependencies") 103 | 104 | ## [Compatibility](#compatibility) 105 | 106 | This role has been tested on these [container images](https://hub.docker.com/u/robertdebock): 107 | 108 | |container|tags| 109 | |---------|----| 110 | |[Alpine](https://hub.docker.com/r/robertdebock/alpine)|all| 111 | |[Amazon](https://hub.docker.com/r/robertdebock/amazonlinux)|Candidate| 112 | |[EL](https://hub.docker.com/r/robertdebock/enterpriselinux)|9| 113 | |[Debian](https://hub.docker.com/r/robertdebock/debian)|all| 114 | |[Fedora](https://hub.docker.com/r/robertdebock/fedora)|all| 115 | |[Ubuntu](https://hub.docker.com/r/robertdebock/ubuntu)|all| 116 | 117 | The minimum version of Ansible required is 2.12, tests have been done to: 118 | 119 | - The previous version. 120 | - The current version. 121 | - The development version. 122 | 123 | If you find issues, please register them in [GitHub](https://github.com/robertdebock/ansible-role-java/issues). 124 | 125 | ## [License](#license) 126 | 127 | [Apache-2.0](https://github.com/robertdebock/ansible-role-java/blob/master/LICENSE). 128 | 129 | ## [Author Information](#author-information) 130 | 131 | [robertdebock](https://robertdebock.nl/) 132 | 133 | Please consider [sponsoring me](https://github.com/sponsors/robertdebock). 134 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | # [Security Policy](#security-policy) 2 | 3 | This software implements other software, it's not very likely that this software introduces new vulnerabilities. 4 | 5 | ## [Supported Versions](#supported-versions) 6 | 7 | These version of [ansible](https://pypi.org/project/ansible/) are supported: 8 | 9 | | Version | Supported | 10 | | ------- | ------------------ | 11 | | 7 | :white_check_mark: | 12 | | 6 | :white_check_mark: | 13 | | 5 | :white_check_mark: | 14 | 15 | ## [Reporting a Vulnerability](#reporting-a-vulnarability) 16 | 17 | Please [open an issue](https://github.com/robertdebock/ansible-role-java/issues) describing the vulnerability. 18 | 19 | Tell them where to go, how often they can expect to get an update on a 20 | reported vulnerability, what to expect if the vulnerability is accepted or 21 | declined, etc. 22 | 23 | Please consider [sponsoring me](https://github.com/sponsors/robertdebock). 24 | -------------------------------------------------------------------------------- /defaults/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # defaults file for java 3 | 4 | # Set the vendor of java, valid values are "openjdk" and "oracle". 5 | java_vendor: openjdk 6 | 7 | # Set the variable to install the type, valid values are "jre" and "jdk". 8 | java_type: jre 9 | 10 | # Set the version of java, valid values are 6, 7, 8, 9, 10, 11, 12, 13 17, 19, 20 or 21. 11 | # By default, a distribution default is used, mapped in `vars/main.yml`. 12 | # By setting java_version, you overwrite this default to your selected 13 | # version. 14 | java_version: "{{ java_default_version }}" 15 | 16 | # Set the format of the installation source, valid values are "deb", "rpm" or "targz". 17 | # This is only valid with "java_vendor == oracle" 18 | java_format: targz 19 | 20 | # Where do the RPMs come from when installing Oracle RPMs? 21 | # Either "local" or "repository". 22 | # Valid for "java_vendor == oracle" and "java_format" == "rpm" 23 | java_source: local 24 | 25 | # Choose if you can JCE installed. Only applicable for (both): 26 | # - java_vendor == "oracle" 27 | # - java_version == "8" 28 | java_jce: true 29 | 30 | # In case of "java_vendor == oracle" and "java_format == targz", a directory 31 | # as to be set where to install. 32 | java_install_directory: /opt 33 | -------------------------------------------------------------------------------- /meta/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | galaxy_info: 3 | author: robertdebock 4 | role_name: java 5 | description: Install and configure java on your system. 6 | license: Apache-2.0 7 | company: none 8 | min_ansible_version: "2.12" 9 | 10 | platforms: 11 | - name: Alpine 12 | versions: 13 | - all 14 | - name: Amazon 15 | versions: 16 | - Candidate 17 | - name: EL 18 | versions: 19 | - "9" 20 | - name: Debian 21 | versions: 22 | - all 23 | - name: Fedora 24 | versions: 25 | - all 26 | - name: Ubuntu 27 | versions: 28 | - all 29 | 30 | galaxy_tags: 31 | - java 32 | - oracle 33 | - openjdk 34 | - jre 35 | - jdk 36 | - alternatives 37 | - system 38 | 39 | dependencies: [] 40 | -------------------------------------------------------------------------------- /meta/preferences.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | matrix_overrides: 4 | amazonlinux: 5 | python: 6 | - python:3.9 7 | - python:3.10 8 | -------------------------------------------------------------------------------- /molecule/default/converge.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Converge 3 | hosts: all 4 | become: true 5 | gather_facts: true 6 | 7 | roles: 8 | - role: robertdebock.java 9 | # To install Oracle java 21 package: 10 | # NOTE: Please download Java yourself, place it in `files/`. 11 | # This is to avoid licensing issues. 12 | # java_source: local 13 | # java_type: jdk 14 | # java_format: deb 15 | # java_version: 21 16 | -------------------------------------------------------------------------------- /molecule/default/molecule.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # 3 | # Ansible managed 4 | # 5 | dependency: 6 | name: galaxy 7 | options: 8 | role-file: requirements.yml 9 | requirements-file: requirements.yml 10 | lint: | 11 | set -e 12 | yamllint . 13 | ansible-lint 14 | driver: 15 | name: docker 16 | platforms: 17 | - name: "java-${image:-fedora}-${tag:-latest}${TOX_ENVNAME}" 18 | image: "${namespace:-robertdebock}/${image:-fedora}:${tag:-latest}" 19 | command: /sbin/init 20 | cgroupns_mode: host 21 | volumes: 22 | - /sys/fs/cgroup:/sys/fs/cgroup:rw 23 | privileged: true 24 | pre_build_image: true 25 | provisioner: 26 | name: ansible 27 | verifier: 28 | name: ansible 29 | -------------------------------------------------------------------------------- /molecule/default/prepare.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Prepare 3 | hosts: all 4 | become: true 5 | gather_facts: false 6 | 7 | roles: 8 | - role: robertdebock.bootstrap 9 | -------------------------------------------------------------------------------- /molecule/default/verify.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Verify 3 | hosts: all 4 | become: true 5 | gather_facts: true 6 | 7 | tasks: 8 | - name: Run java -version 9 | ansible.builtin.command: 10 | cmd: java -version 11 | changed_when: false 12 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | molecule 2 | molecule-plugins[docker] 3 | paramiko 4 | -------------------------------------------------------------------------------- /requirements.yml: -------------------------------------------------------------------------------- 1 | --- 2 | roles: 3 | - name: robertdebock.bootstrap 4 | collections: 5 | - name: community.general 6 | -------------------------------------------------------------------------------- /tasks/assert.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | - name: assert | Test java_vendor 4 | ansible.builtin.assert: 5 | that: 6 | - java_vendor is defined 7 | - java_vendor is string 8 | - java_vendor in [ "openjdk", "oracle" ] 9 | quiet: true 10 | 11 | - name: assert | Test java_type 12 | ansible.builtin.assert: 13 | that: 14 | - java_type is defined 15 | - java_type is string 16 | - java_type in [ "jre", "jdk" ] 17 | quiet: true 18 | 19 | - name: assert | Test java_version 20 | ansible.builtin.assert: 21 | that: 22 | - java_version | int is number 23 | - java_version | int in [ 6, 7, 8, 9, 10, 11, 12, 13, 17, 19, 20, 21 ] 24 | quiet: true 25 | when: 26 | - java_version is defined 27 | 28 | - name: assert | Test java_format 29 | ansible.builtin.assert: 30 | that: 31 | - java_format is defined 32 | - java_format is string 33 | - java_format in [ "deb", "rpm", "targz" ] 34 | quiet: true 35 | 36 | - name: assert | Test java_rpm_source 37 | ansible.builtin.assert: 38 | that: 39 | - java_rpm_source is defined 40 | - java_rpm_source is string 41 | - java_rpm_source in [ "local", "repository" ] 42 | quiet: true 43 | when: 44 | - java_vendor == "oracle" 45 | - java_format == "rpm" 46 | 47 | - name: assert | Test java_jce 48 | ansible.builtin.assert: 49 | that: 50 | - java_jce is defined 51 | - java_jce is boolean 52 | quiet: true 53 | when: 54 | - java_vendor == "oracle" 55 | - java_version == 8 56 | 57 | - name: assert | Test java_install_directory 58 | ansible.builtin.assert: 59 | that: 60 | - java_install_directory is defined 61 | - java_install_directory is string 62 | - java_install_directory is not none 63 | quiet: true 64 | when: 65 | - java_vendor == "oracle" 66 | - java_format == "targz" 67 | -------------------------------------------------------------------------------- /tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # tasks file for java 3 | 4 | - name: Import assert.yml 5 | ansible.builtin.import_tasks: 6 | file: assert.yml 7 | run_once: true 8 | delegate_to: localhost 9 | 10 | - name: Install requirements 11 | ansible.builtin.package: 12 | name: bash 13 | state: present 14 | 15 | - name: Install openjdk java (package) 16 | ansible.builtin.package: 17 | name: "{{ java_openjdk_package }}" 18 | state: present 19 | when: 20 | java_vendor == "openjdk" 21 | environment: 22 | USE: "X -cups -alsa -fontconfig" 23 | 24 | - name: Install RPM 25 | when: 26 | - java_source == "local" 27 | - java_format == "rpm" 28 | block: 29 | - name: Copy oracle java (rpm) 30 | ansible.builtin.copy: 31 | src: "{{ java_package }}" 32 | dest: "/tmp/{{ java_package }}" 33 | mode: "0640" 34 | 35 | - name: Install oracle java (rpm) (local) 36 | ansible.builtin.package: 37 | name: "/tmp/{{ java_package }}" 38 | state: present 39 | 40 | - name: Install DEB 41 | when: 42 | - java_source == "local" 43 | - java_format == "deb" 44 | block: 45 | - name: Copy oracle java (deb) 46 | ansible.builtin.copy: 47 | src: "{{ java_package }}" 48 | dest: "/tmp/{{ java_package }}" 49 | mode: "0640" 50 | 51 | - name: Install oracle java (deb) (local) 52 | ansible.builtin.apt: 53 | deb: "/tmp/{{ java_package }}" 54 | state: present 55 | 56 | - name: Install oracle java (rpm) (repository) 57 | ansible.builtin.package: 58 | name: "{{ java_oracle_package }}" 59 | state: present 60 | when: 61 | - java_source == "repository" 62 | - java_format == "rpm" 63 | 64 | - name: Configure oracle targz 65 | when: 66 | - java_format == "targz" 67 | - java_vendor == "oracle" 68 | block: 69 | - name: Ensure java_install_directory exists 70 | ansible.builtin.file: 71 | path: "{{ java_install_directory }}" 72 | state: directory 73 | mode: "0755" 74 | 75 | - name: Install oracle java (targz) 76 | ansible.builtin.unarchive: 77 | src: "{{ java_oracle_package }}" 78 | dest: "{{ java_install_directory }}" 79 | mode: "0755" 80 | 81 | - name: Install oracle java policy software (targz) 82 | ansible.builtin.unarchive: 83 | src: jce_policy-8.zip 84 | dest: "{{ java_install_directory }}" 85 | mode: "0755" 86 | when: 87 | - java_jce 88 | - java_version == 8 89 | - java_vendor == "oracle" 90 | 91 | - name: Set alternative (targz) 92 | community.general.alternatives: 93 | name: java 94 | link: /usr/bin/java 95 | path: "{{ java_install_directory }}/{{ java_oracle_directory }}/bin/java" 96 | when: 97 | - java_format == "targz" 98 | - ansible_distribution != "Alpine" 99 | - java_vendor == "oracle" 100 | 101 | - name: Find JAVA_HOME 102 | ansible.builtin.shell: 103 | cmd: set -o pipefail && readlink -f /usr/bin/java | sed 's%/bin/java%%' 104 | executable: /bin/bash 105 | changed_when: false 106 | check_mode: false 107 | register: java_home 108 | 109 | - name: Set JAVA_HOME in /etc/environment 110 | ansible.builtin.lineinfile: 111 | path: /etc/profile.d/java_home.sh 112 | regexp: '^export JAVA_HOME=' 113 | line: 'export JAVA_HOME="{{ java_home.stdout }}"' 114 | create: true 115 | mode: "0644" 116 | -------------------------------------------------------------------------------- /tox.ini: -------------------------------------------------------------------------------- 1 | [tox] 2 | envlist = ansible-2.{15,16,17,18} 3 | skipsdist = true 4 | 5 | [testenv] 6 | commands = molecule test 7 | 8 | setenv = 9 | TOX_ENVNAME={envname} 10 | PY_COLORS=1 11 | ANSIBLE_FORCE_COLOR=1 12 | ANSIBLE_ROLES_PATH=../ 13 | 14 | passenv = * 15 | 16 | # Test supported releases of ansible-core. See: 17 | # https://docs.ansible.com/ansible/latest/reference_appendices/release_and_maintenance.html#ansible-core-support-matrix 18 | 19 | [testenv:ansible-2.15] 20 | basepython = python3.9 21 | deps = 22 | -rrequirements.txt 23 | ansible-core==2.15.* 24 | ansible-lint==6.* 25 | 26 | [testenv:ansible-2.16] 27 | basepython = python3.10 28 | deps = 29 | -rrequirements.txt 30 | ansible-core==2.16.* 31 | ansible-lint==24.* 32 | 33 | [testenv:ansible-2.17] 34 | basepython = python3.10 35 | deps = 36 | -rrequirements.txt 37 | ansible-core==2.17.* 38 | ansible-lint==24.* 39 | 40 | [testenv:ansible-2.18] 41 | basepython = python3.13 42 | deps = 43 | -rrequirements.txt 44 | ansible-core==2.18.* 45 | ansible-lint==24.* 46 | -------------------------------------------------------------------------------- /vars/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # vars file for java 3 | 4 | # This part maps a distribution to a version of java. 5 | _java_default_version: 6 | default: 11 7 | Alpine: 8 8 | Amazon: 17 9 | Debian-12: 17 10 | Fedora: 21 11 | Gentoo: 8 12 | RedHat: 11 13 | Ubuntu: 19 14 | Ubuntu-18: 17 15 | Ubuntu-20: 17 16 | Ubuntu-24: 21 17 | Suse: 8 18 | java_default_version: "{{ _java_default_version[ansible_distribution ~ '-' ~ ansible_distribution_major_version] | default(_java_default_version[ansible_distribution] | default(_java_default_version[ansible_os_family] | default(_java_default_version['default'] ))) }}" 19 | 20 | # This part maps the type of java package (jre/jdk) to a package name 21 | # for the distribution. 22 | _java_openjdk_package: 23 | jre: 24 | 6: 25 | default: java-1.6.0-openjdk 26 | 7: 27 | default: java-1.7.0-openjdk 28 | Alpine: openjdk7-jre-base 29 | openSUSE Leap: java-1_7_0-openjdk 30 | 8: 31 | default: java-1.8.0-openjdk 32 | Alpine: openjdk8-jre-base 33 | Debian: openjdk-8-jre 34 | Fedora: java-1.8.0-openjdk-headless 35 | Gentoo: jre 36 | Ubuntu: openjdk-8-jre 37 | openSUSE Leap: java-1_8_0-openjdk 38 | 9: 39 | default: openjdk-9-jre 40 | 10: 41 | default: openjdk-10-jre 42 | 11: 43 | default: java-11-openjdk 44 | Debian: openjdk-11-jre 45 | Fedora: java-11-openjdk-headless 46 | Ubuntu: openjdk-11-jre 47 | 12: 48 | default: openjdk-12-jre 49 | 13: 50 | default: openjdk-13-jre 51 | 17: 52 | default: openjdk-17-jre 53 | Amazon: java-17-amazon-corretto 54 | Fedora: java-17-openjdk-headless 55 | 19: 56 | default: openjdk-19-jre 57 | 21: 58 | default: openjdk-21-jre 59 | Fedora: java-21-openjdk-headless 60 | jdk: 61 | 6: 62 | default: java-1.6.0-openjdk-devel 63 | 7: 64 | default: java-1.7.0-openjdk-devel 65 | Alpine: openjdk7 66 | openSUSE Leap: java-1_7_0-openjdk-devel 67 | 8: 68 | default: java-1.8.0-openjdk-devel 69 | Alpine: openjdk8 70 | Debian: openjdk-8-jdk 71 | Gentoo: jdk 72 | Ubuntu: openjdk-8-jdk 73 | openSUSE Leap: java-1_8_0-openjdk-devel 74 | 9: 75 | default: java-9-openjdk-devel 76 | Ubuntu: openjdk-9-jdk 77 | 10: 78 | default: openjdk-10-jdk 79 | 11: 80 | default: java-11-openjdk-devel 81 | Debian: openjdk-11-jdk 82 | Ubuntu: openjdk-11-jdk 83 | 12: 84 | default: openjdk-12-jdk 85 | 13: 86 | default: openjdk-13-jdk 87 | 17: 88 | default: openjdk-17-jdk 89 | Amazon: java-17-amazon-corretto-devel 90 | 19: 91 | default: openjdk-19-jdk 92 | 21: 93 | default: openjdk-21-jdk 94 | java_openjdk_package: "{{ _java_openjdk_package[java_type][java_version | int][ansible_distribution] | default(_java_openjdk_package[java_type][java_version | int]['default'] | default([])) }}" 95 | 96 | _java_package: 97 | jre: 98 | 8: 99 | deb: jre-8u191-linux-x64.deb 100 | rpm: jre-8u191-linux-x64.rpm 101 | targz: jre-8u191-linux-x64.tar.gz 102 | 10: 103 | deb: jre-10.0.2_linux-x64_bin.deb 104 | rpm: jre-10.0.2_linux-x64_bin.rpm 105 | targz: jre-10.0.2_linux-x64_bin.tar.gz 106 | jdk: 107 | 8: 108 | deb: jdk-8u191-linux-x64.deb 109 | rpm: jdk-8u191-linux-x64.rpm 110 | targz: jdk-8u191-linux-x64.tar.gz 111 | 10: 112 | deb: jdk-10.0.2_linux-x64_bin.deb 113 | rpm: jdk-10.0.2_linux-x64_bin.rpm 114 | targz: jdk-10.0.2_linux-x64_bin.tar.gz 115 | 21: 116 | deb: jdk-21_linux-x64_bin.deb 117 | rpm: jdk-21_linux-x64_bin.rpm 118 | java_package: "{{ _java_package[java_type][java_version][java_format] | default([]) }}" 119 | --------------------------------------------------------------------------------