Skip to content

Commit

Permalink
Add logic to install all packages at once after adding them to jws_de…
Browse files Browse the repository at this point in the history
…pendencies_list
  • Loading branch information
dsoumis committed Oct 10, 2023
1 parent 0f31ffb commit 8d0a312
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 26 deletions.
2 changes: 1 addition & 1 deletion roles/jws/tasks/fastpackage.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
- name: "Check if \"{{ packages_list | join(', ') }}\" packages are already installed" # noqa command-instead-of-module this runs faster
- name: "Check if \"{{ packages_list | join(', ') }}\" packages are already installed" # noqa command-instead-of-module this runs faster
ansible.builtin.command: "rpm -q {{ packages_list | join(' ') }}"
register: rpm_info
changed_when: False
Expand Down
14 changes: 4 additions & 10 deletions roles/jws/tasks/java_install.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
---
- name: "Install java"
- name: "Install Java"
when:
- jws_java_version is defined
- ansible_os_family == "RedHat"
block:
- name: Set rpm name with version
- name: "Add 'java-{{ jws_java_version }}-openjdk-headless' to dependencies list"
ansible.builtin.set_fact:
jws_java_packages_el: "java-{{ jws_java_version }}-openjdk-headless"
jws_dependencies_list: "{{ jws_dependencies_list + ['java-{{ jws_java_version }}-openjdk-headless'] }}"

- name: "Install {{ jws_java_packages_el }}"
ansible.builtin.include_tasks: fastpackage.yml
vars:
packages_list:
- "{{ jws_java_packages_el }}"

- name: Determine JAVA_HOME for selected JVM RPM
- name: "Determine JAVA_HOME for selected JVM RPM"
ansible.builtin.set_fact:
rpm_java_home: "/etc/alternatives/jre_{{ jws_java_version }}"
27 changes: 12 additions & 15 deletions roles/jws/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,25 +27,27 @@
- jws_home is defined
- jws_home | length > 0

- name: "Add firewalld to dependencies list (if enabled)."
- name: "Add firewalld to dependencies list (if enabled)"
ansible.builtin.set_fact:
jws_dependencies_list: "{{ [ jws_dependencies_list + jws_firewalld_package_name ] }}"
jws_dependencies_list: "{{ jws_dependencies_list + jws_firewalld_package_name }}"
when:
- jws_firewalld_enabled is defined and jws_firewalld_enabled

- name: "Add 'openssl' and 'apr' to dependencies list required for natives (if enabled)"
ansible.builtin.set_fact:
jws_dependencies_list: "{{ jws_dependencies_list + ['openssl', 'apr'] }}"
when: jws_native

- name: "Include tasks for Java installation (if Java version is provided)"
ansible.builtin.include_tasks: java_install.yml
when:
- jws_java_version is defined

- name: "Install required dependencies"
ansible.builtin.include_tasks: fastpackage.yml
vars:
packages_list: "{{ jws_dependencies_list }}"

- name: "Install required dependencies for natives"
ansible.builtin.include_tasks: fastpackage.yml
vars:
packages_list:
- openssl
- apr
when: jws_native

- name: "Ensure tomcatjss rpm is not installed"
ansible.builtin.dnf:
name: tomcatjss
Expand All @@ -54,11 +56,6 @@
- jws.check_jws_ss_absent is defined
- jws.check_jws_ss_absent

- name: "Include tasks for java jvm installation"
ansible.builtin.include_tasks: java_install.yml
when:
- jws_java_version is defined

- name: Check user/groups and whether force install needed
block:
- name: "Create group: {{ jws.group }}"
Expand Down

0 comments on commit 8d0a312

Please sign in to comment.