Skip to content

Commit

Permalink
Update fastpackage.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
dsoumis committed Oct 10, 2023
1 parent 49a8580 commit a20ac16
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 30 deletions.
32 changes: 15 additions & 17 deletions roles/jws/tasks/fastpackage.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
---
- name: Check arguments
ansible.builtin.assert:
that:
- package_name is defined
quiet: true
- name: "Check if \"{{ packages_list | join(', ') }}\" packages are already installed" # noqa command-instead-of-module this runs faster

Check warning on line 2 in roles/jws/tasks/fastpackage.yml

View workflow job for this annotation

GitHub Actions / ci / linter (3.11, 2.15)

yaml[comments]

Too few spaces before comment
ansible.builtin.command: "rpm -q {{ packages_list | join(' ') }}"
register: rpm_info
changed_when: False
failed_when: False

- name: "Install package"
block:
- name: "Test if package {{ package_name }} is already installed"
ansible.builtin.command: rpm -q {{ package_name }}
register: rpm_info
changed_when: rpm_info.failed
rescue:
- name: "Install package {{ package_name }} using yum if missing"
ansible.builtin.yum:
name: "{{ package_name }}"
state: installed
when: rpm_info.failed
- name: "Add missing packages to the yum install list"
ansible.builtin.set_fact:
packages_to_install: "{{ packages_to_install | default([]) + rpm_info.stdout_lines | map('regex_findall', 'package (.+) is not installed$') | default([]) | flatten }}"

- name: "Install packages: {{ packages_to_install }}"
become: True
ansible.builtin.yum:
name: "{{ packages_to_install }}"
state: present
when: packages_to_install | default([]) | length > 0
3 changes: 2 additions & 1 deletion roles/jws/tasks/java_install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
- name: "Install {{ jws_java_packages_el }}"
ansible.builtin.include_tasks: fastpackage.yml
vars:
package_name: "{{ jws_java_packages_el }}"
packages_list:
- "{{ jws_java_packages_el }}"

- name: Determine JAVA_HOME for selected JVM RPM
ansible.builtin.set_fact:
Expand Down
10 changes: 4 additions & 6 deletions roles/jws/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,14 @@
- name: "Install required dependencies"
ansible.builtin.include_tasks: fastpackage.yml
vars:
package_name: "{{ item }}"
loop: "{{ jws_dependencies_list }}"
packages_list: "{{ jws_dependencies_list }}"

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

- name: "Ensure tomcatjss rpm is not installed"
Expand Down
3 changes: 2 additions & 1 deletion roles/jws/tasks/systemd/selinux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
- name: Install selinux-policy-devel
ansible.builtin.include_tasks: ../fastpackage.yml
vars:
package_name: selinux-policy-devel
packages_list:
- selinux-policy-devel

- name: Check if archive contains a selinux policy
ansible.builtin.stat:
Expand Down
9 changes: 4 additions & 5 deletions roles/jws/tasks/systemd/systemd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,10 @@

- name: "Ensure requirements for systemd"
ansible.builtin.include_tasks: ../fastpackage.yml
loop_control:
loop_var: package_name
loop:
- systemd
- procps-ng
vars:
packages_list:
- systemd
- procps-ng

- name: "Set required default for jws_service_conf if not provided."
ansible.builtin.set_fact:
Expand Down

0 comments on commit a20ac16

Please sign in to comment.