{"id":16780917,"url":"https://github.com/morgangraphics/ansible-role-java","last_synced_at":"2025-03-16T20:22:08.750Z","repository":{"id":149178762,"uuid":"95937712","full_name":"morgangraphics/ansible-role-java","owner":"morgangraphics","description":"Java Ansible Role that Installs Java on Debian/Ubuntu/RHEL/CentOS","archived":false,"fork":false,"pushed_at":"2019-10-28T15:41:13.000Z","size":14,"stargazers_count":1,"open_issues_count":3,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-23T06:45:35.476Z","etag":null,"topics":["ansible-role","ansible-roles","java","java-ansible-role"],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/morgangraphics.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-07-01T02:42:32.000Z","updated_at":"2021-05-22T13:44:24.000Z","dependencies_parsed_at":null,"dependency_job_id":"ef7a7296-324c-4442-843c-37a26c03fffd","html_url":"https://github.com/morgangraphics/ansible-role-java","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/morgangraphics%2Fansible-role-java","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/morgangraphics%2Fansible-role-java/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/morgangraphics%2Fansible-role-java/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/morgangraphics%2Fansible-role-java/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/morgangraphics","download_url":"https://codeload.github.com/morgangraphics/ansible-role-java/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243926016,"owners_count":20369914,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ansible-role","ansible-roles","java","java-ansible-role"],"created_at":"2024-10-13T07:36:16.980Z","updated_at":"2025-03-16T20:22:08.725Z","avatar_url":"https://github.com/morgangraphics.png","language":null,"readme":"# Ansible Role: Java\n\nInstalls JAVA on Debian/Ubuntu and RHEL/CentOS\n\n\nThe purpose of this Role is to leave the default OS as intact as possible. As a result there are things that are installed used and then uninstalled or not installed at all to preserve that methodology.\n\nI try to preserve backwards compatibility wherever possible as long as it makes sense. For example, RedHat's new Package manager DNF could be switched to YUM to install OpenJDK 1.7. However, that violates the purpose of the methodology to leave the default OS intact. As a result I drop support for OpenJDK 1.7 on newer versions of RedHat because that is the default action RedHat takes. However, older versions of RedHat and/or AWS Flavors of Linux are covered as long as YUM is the default Package Manager.\n\n\n## Unsupported Java versions\nSupport for Oracle Java 6 and 7 were removed from public download in June of 2017.\nThis means you need a Oracle support contract to get access to them.\n\nFrom Oracle [downloads page](http://www.oracle.com/technetwork/java/javase/downloads/index-jsp-138363.html)\n\n \u003e \"Updates for Java SE 7 released after April 2015, and updates for Java SE 6 released after April 2013 are only available to Oracle Customers through My Oracle Support (requires support login).\n\n \u003e Java SE Advanced offers users commercial features, access to critical bug fixes, security fixes, and general maintenance\".\n\nThis Ansible role **does not provide support** for Oracle Java 6/7 or Oracle JRE\n\nThe Oracle JRE versions of Java change frequently and require manual download and installation. While this role could be scripted to handle such tasks, there is no need for me to do so at this time. Others have taken it upon themselves to handle the [insanity involved in doing so](https://gist.github.com/P7h/9741922)\n\n## Supported Java versions\n\n### Ubuntu\n|             | JDK      | JRE      |\n|-------------|----------|----------|\n| **Oracle**  | 8,9      |          |\n| **OpenJDK** | 6,7,8,9+ | 6,7,8,9+ |\n\n\n### RHEL DNF (Fedora 21 +)\n|             | JDK     | JRE     |\n|-------------|---------|---------|\n| **Oracle**  | 8,9     |         |\n| **OpenJDK** | 8,9+    | 8,9+    |\n\n\n### RHEL/CentOS YUM\n|             | JDK      | JRE      |\n|-------------|----------|----------|\n| **Oracle**  | 8,9      |          |\n| **OpenJDK** | 6,7,8,9+ | 6,7,8,9+ |\n\n\n```\n- role: ansible-role-java\n  install_type: jdk\n  java_version: openjdk-7\n```\n\nThe above **WILL NOT** work for RedHat (Fedora \u003e 21). However, it is still perfectly valid for CentOS and older versions of RedHat (Fedora \u003c 21)\n\n\n## Example Playbooks\n\nNaming convention is {oracle|openjdk}-{version}\n\ne.g. `oracle-8` or `openjdk-9`\n\n\n#### Simple\n``` yaml\n- hosts: all\n  roles:\n    # Installs openjdk-8-jre by default\n    - role: ansible-role-java\n```\n\n``` yaml\n- hosts: all\n  roles:\n    # Installs openjdk-8-jdk\n    - role: ansible-role-java\n      install_type: \"jdk\"\n      java_home: False\n\n```\n#### More Complex\n``` yaml\n- hosts: dev1\n  roles:\n    - role: ansible-role-java\n      java_version: \"oracle-8\"\n\n- hosts: dev2\n  roles:\n    # Install OpenJDK 7,8 \u0026 9 JRE setting 8 as the Default\n    - role: ansible-role-java\n      install_type: \"jdk\"\n      java_version: \"openjdk-7\"\n\n    - role: ansible-role-java\n      install_type: \"jdk\"\n      java_version: \"openjdk-8\"\n      default: true\n\n    - role: ansible-role-java\n      java_version: \"openjdk-9\"\n\n```\n\n\n## Notes\n\nThis role runs as `root` user\n\nThis role takes advantage of APT/DF/YUM default JAVA repository version for the version of the OS you are using; meaning just including the role will install **openjdk-8-jre** by default. **This should suffice for most applications** unless, for example, the default JAVA repository version is `openjdk-9-jre` for your OS.\n\nAny Oracle versions of Java are **JDK** by default (JDK also includes JRE)\n\nIf installing multiple versions of Java, last one installed is set as default unless specified\n\n`openjdk-6` is not supported on Ubuntu 16.04 Xenial or RHEL Fedora 21+\n`openjdk-7` is not supported on RHEL Fedora 21+\n\n[Ubuntu Environment Variables](https://help.ubuntu.com/community/EnvironmentVariables) are a little tricky\n\n`.bashrc` file is run each time a **user** logs in which is fine for most applications where a user interacts with a machine.\n\n  ```bash\n  export JAVA_HOME=/usr/lib/jvm/jdk1.8.0\n  ```\n\n`/etc/environment` is a system wide file that isn't tied to a specific user, **however** it **WILL NOT** allow for variable expansion e.g. `$HOME` and must be declared with an absolute path e.g. `JAVA_HOME=/usr/lib/jvm/jdk1.8.0`.\n\n  ```bash\n  JAVA_HOME=/usr/lib/jvm/jdk1.8.0\n  ```\n\nWhen you need something a little more flexible adding a `\u003cYOUR SCRIPT NAME\u003e.sh` script to `/etc/profile.d/` directory works equally well. **However**, you must explicitly define the script path including name.\n\n  ```bash\n  export JAVA_HOME=/usr/lib/jvm/jdk1.8.0\n  export PATH=$PATH:$JAVA_HOME/bin\n  ```\n\n\n## Role Variables\n\nAvailable variables are listed below, along with default values see [defaults/main.yml]( defaults/main.yml)\n\nRun System Update before Install\n*It is recommended that this be set to true, however, if you do this as part of another step this can be false*\n\n    system_update: true\n\nThe Java type version to install. Options are `jre` or `jdk`\n\n    install_type: \"jre\"\n\nJava version to install\n\nOptions are: `default (openjdk-8)`, `openjdk-6`, `openjdk-7`, `openjdk-8`, `openjdk-9`, `oracle-8`, `oracle-9`\n\n    java_version: \"default\"\n\n\nSet default version of Java when installing multiple versions\n\n    default: false\n\nSet `$JAVA_HOME` Environment variable on the system\n\n    java_home: true\n\nLocation to set the `$JAVA_HOME` Environment variable at path or in script file\n\nOptions are:\n`/etc/environment`, `.bashrc`, or `/etc/profile.d/\u003cYOUR SCRIPT NAME\u003e.sh`\n\n    java_home_path: /etc/environment\n\n\n## TODO:\n1. RedHat Oracle Install\nhttps://github.com/ansiblebit/oracle-java/blob/master/tasks/redhat/main.yml\n\n## Dependencies\n\nNone.\n\n\n\n## License\n\nMIT / BSD\n\n## Author Information\n\ndm00000 via MORGANGRAPHICS, INC\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmorgangraphics%2Fansible-role-java","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmorgangraphics%2Fansible-role-java","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmorgangraphics%2Fansible-role-java/lists"}