Skip to content
This repository has been archived by the owner on Jan 15, 2024. It is now read-only.

Commit

Permalink
use flat names for variables rather than nested
Browse files Browse the repository at this point in the history
  • Loading branch information
p-j-smith committed Oct 20, 2023
1 parent c3d0239 commit b309ebc
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 29 deletions.
27 changes: 9 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,40 +1,31 @@
Ansible Role: mirsg.java
=========
# Ansible Role: mirsg.java

A role for install and configuring Java.

Role Variables
--------------
## Role Variables

`java` - A dictionary containing:
`java_profile_d`: Defaults to "/etc/profile.d".

`profile_d`: Defaults to "/etc/profile.d".
`java_home`: Defaults to "/usr/lib/jvm/jre"

`home`: Defaults to "/usr/lib/jvm/jre"
`java_package`: Defaults to "java-1.8.0-openjdk-devel"

`package`: Defaults to "java-1.8.0-openjdk-devel"

`keystore_path`: Defaults to "/usr/lib/jvm/jre/lib/security/cacerts/"

Example Playbook
----------------
## Example Playbook

Including an example of how to use your role (for instance, with variables
passed in as parameters) is always nice for users too:

```yaml
- hosts: servers
roles:
- { role: mirsg.java }
- { role: mirsg.java }
```
License
-------
## License
BSD
Author Information
------------------
## Author Information
This role was created by the [Medical Imaging Research Software
Group](https://www.ucl.ac.uk/advanced-research-computing/expertise/research-software-development/medical-imaging-research-software-group)
Expand Down
10 changes: 4 additions & 6 deletions defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
---
# defaults file for ../ansible-role-install-java
java:
profile_d: "/etc/profile.d"
home: "/usr/lib/jvm/jre"
package: "java-1.8.0-openjdk-devel"
keystore_path: "/usr/lib/jvm/jre/lib/security/cacerts/"
java_profile_d: "/etc/profile.d"
java_home: "/usr/lib/jvm/jre"
java_package: "java-1.8.0-openjdk-devel"
java_keystore_path: "/usr/lib/jvm/jre/lib/security/cacerts/"
8 changes: 4 additions & 4 deletions tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
---
- name: Ensure correct Java version is installed - {{ java.package }}
- name: Ensure correct Java version is installed - {{ java_package }}
ansible.builtin.package:
name: "{{ java.package }}"
name: "{{ java_package }}"
state: installed

- name: Set JAVA_HOME through shell script
ansible.builtin.template:
src: "java_home.sh.j2"
dest: "{{ java.profile_d }}/java_home.sh"
dest: "{{ java_profile_d }}/java_home.sh"
mode: "0644"
when: java.home is defined and java.home != ''
when: java_home is defined and java_home != ''
2 changes: 1 addition & 1 deletion templates/java_home.sh.j2
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export JAVA_HOME="{{ java.home }}"
export JAVA_HOME="{{ java_home }}"

0 comments on commit b309ebc

Please sign in to comment.