From b309ebc48bc938eba61c63a522d04d2f9809ffe2 Mon Sep 17 00:00:00 2001 From: Paul Smith Date: Fri, 20 Oct 2023 10:47:14 +0100 Subject: [PATCH] use flat names for variables rather than nested --- README.md | 27 +++++++++------------------ defaults/main.yml | 10 ++++------ tasks/main.yml | 8 ++++---- templates/java_home.sh.j2 | 2 +- 4 files changed, 18 insertions(+), 29 deletions(-) diff --git a/README.md b/README.md index cc1610a..2676796 100644 --- a/README.md +++ b/README.md @@ -1,23 +1,16 @@ -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: @@ -25,16 +18,14 @@ 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) diff --git a/defaults/main.yml b/defaults/main.yml index 7ee0e8a..f8014c6 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -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/" diff --git a/tasks/main.yml b/tasks/main.yml index e24fd0c..e6b4ef4 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -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 != '' diff --git a/templates/java_home.sh.j2 b/templates/java_home.sh.j2 index ab5bbdb..571fab8 100644 --- a/templates/java_home.sh.j2 +++ b/templates/java_home.sh.j2 @@ -1 +1 @@ -export JAVA_HOME="{{ java.home }}" +export JAVA_HOME="{{ java_home }}"