Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update fastpackage.yml #251

Merged
merged 4 commits into from
Oct 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
13 changes: 4 additions & 9 deletions roles/jws/tasks/java_install.yml
Original file line number Diff line number Diff line change
@@ -1,18 +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:
package_name: "{{ 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 }}"
31 changes: 13 additions & 18 deletions roles/jws/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,26 @@
- 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: "Install required dependencies"
ansible.builtin.include_tasks: fastpackage.yml
vars:
package_name: "{{ item }}"
loop: "{{ jws_dependencies_list }}"
- 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: "Install required dependencies for natives"
- 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:
package_name: "{{ item }}"
loop:
- openssl
- apr
when: jws_native
packages_list: "{{ jws_dependencies_list }}"

- name: "Ensure tomcatjss rpm is not installed"
ansible.builtin.dnf:
Expand All @@ -43,11 +43,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
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
Loading