From c1c152f7acb931021acb3854a070958ca636c540 Mon Sep 17 00:00:00 2001 From: Slavi Pantaleev Date: Sat, 5 Nov 2022 08:31:22 +0200 Subject: [PATCH] Include potentially distro-specific tasks at runtime This avoids Ansible trying to ensure `community.general.pacman` is available, even if that module will never run (because `when` says so). Related to https://github.com/spantaleev/matrix-docker-ansible-deploy/issues/2228 --- .../tasks/util/ensure_fuse_installed.yml | 21 +++++-------------- .../util/ensure_fuse_installed_archlinux.yml | 6 ++++++ .../util/ensure_fuse_installed_debian.yml | 6 ++++++ .../util/ensure_fuse_installed_redhat.yml | 6 ++++++ .../tasks/util/ensure_openssl_installed.yml | 21 +++++-------------- .../ensure_openssl_installed_archlinux.yml | 6 ++++++ .../util/ensure_openssl_installed_debian.yml | 6 ++++++ .../util/ensure_openssl_installed_redhat.yml | 6 ++++++ 8 files changed, 46 insertions(+), 32 deletions(-) create mode 100644 roles/custom/matrix-base/tasks/util/ensure_fuse_installed_archlinux.yml create mode 100644 roles/custom/matrix-base/tasks/util/ensure_fuse_installed_debian.yml create mode 100644 roles/custom/matrix-base/tasks/util/ensure_fuse_installed_redhat.yml create mode 100644 roles/custom/matrix-base/tasks/util/ensure_openssl_installed_archlinux.yml create mode 100644 roles/custom/matrix-base/tasks/util/ensure_openssl_installed_debian.yml create mode 100644 roles/custom/matrix-base/tasks/util/ensure_openssl_installed_redhat.yml diff --git a/roles/custom/matrix-base/tasks/util/ensure_fuse_installed.yml b/roles/custom/matrix-base/tasks/util/ensure_fuse_installed.yml index 240a5c625..a23c77e1c 100644 --- a/roles/custom/matrix-base/tasks/util/ensure_fuse_installed.yml +++ b/roles/custom/matrix-base/tasks/util/ensure_fuse_installed.yml @@ -1,23 +1,12 @@ --- + # This is for both RedHat 7 and 8 -- name: Ensure fuse installed (RedHat) - ansible.builtin.yum: - name: - - fuse - state: present +- ansible.builtin.include_tasks: "{{ role_path }}/tasks/util/ensure_fuse_installed_redhat.yml" when: ansible_os_family == 'RedHat' # This is for both Debian and Raspbian -- name: Ensure fuse installed (Debian/Raspbian) - ansible.builtin.apt: - name: - - fuse - state: present +- ansible.builtin.include_tasks: "{{ role_path }}/tasks/util/ensure_fuse_installed_debian.yml" when: ansible_os_family == 'Debian' -- name: Ensure fuse installed (Archlinux) - community.general.pacman: - name: - - fuse3 - state: present - when: ansible_distribution == 'Archlinux' +- ansible.builtin.include_tasks: "{{ role_path }}/tasks/util/ensure_fuse_installed_archlinux.yml" + when: ansible_os_family == 'Archlinux' diff --git a/roles/custom/matrix-base/tasks/util/ensure_fuse_installed_archlinux.yml b/roles/custom/matrix-base/tasks/util/ensure_fuse_installed_archlinux.yml new file mode 100644 index 000000000..676543d83 --- /dev/null +++ b/roles/custom/matrix-base/tasks/util/ensure_fuse_installed_archlinux.yml @@ -0,0 +1,6 @@ +--- + +- name: Ensure fuse installed (Archlinux) + community.general.pacman: + name: fuse3 + state: present diff --git a/roles/custom/matrix-base/tasks/util/ensure_fuse_installed_debian.yml b/roles/custom/matrix-base/tasks/util/ensure_fuse_installed_debian.yml new file mode 100644 index 000000000..b9491eb49 --- /dev/null +++ b/roles/custom/matrix-base/tasks/util/ensure_fuse_installed_debian.yml @@ -0,0 +1,6 @@ +--- + +- name: Ensure fuse installed (Debian/Raspbian) + ansible.builtin.apt: + name: fuse + state: present diff --git a/roles/custom/matrix-base/tasks/util/ensure_fuse_installed_redhat.yml b/roles/custom/matrix-base/tasks/util/ensure_fuse_installed_redhat.yml new file mode 100644 index 000000000..878fb5682 --- /dev/null +++ b/roles/custom/matrix-base/tasks/util/ensure_fuse_installed_redhat.yml @@ -0,0 +1,6 @@ +--- + +- name: Ensure fuse installed (RedHat) + ansible.builtin.yum: + name: fuse + state: present diff --git a/roles/custom/matrix-base/tasks/util/ensure_openssl_installed.yml b/roles/custom/matrix-base/tasks/util/ensure_openssl_installed.yml index a5bdf21a5..a3b73d680 100644 --- a/roles/custom/matrix-base/tasks/util/ensure_openssl_installed.yml +++ b/roles/custom/matrix-base/tasks/util/ensure_openssl_installed.yml @@ -1,23 +1,12 @@ --- + # This is for both RedHat 7 and 8 -- name: Ensure openssl installed (RedHat) - ansible.builtin.yum: - name: - - openssl - state: present +- ansible.builtin.include_tasks: "{{ role_path }}/tasks/util/ensure_openssl_installed_redhat.yml" when: ansible_os_family == 'RedHat' # This is for both Debian and Raspbian -- name: Ensure openssl installed (Debian/Raspbian) - ansible.builtin.apt: - name: - - openssl - state: present +- ansible.builtin.include_tasks: "{{ role_path }}/tasks/util/ensure_openssl_installed_debian.yml" when: ansible_os_family == 'Debian' -- name: Ensure openssl installed (Archlinux) - community.general.pacman: - name: - - openssl - state: present - when: ansible_distribution == 'Archlinux' +- ansible.builtin.include_tasks: "{{ role_path }}/tasks/util/ensure_openssl_installed_archlinux.yml" + when: ansible_os_family == 'Archlinux' diff --git a/roles/custom/matrix-base/tasks/util/ensure_openssl_installed_archlinux.yml b/roles/custom/matrix-base/tasks/util/ensure_openssl_installed_archlinux.yml new file mode 100644 index 000000000..ce70c5624 --- /dev/null +++ b/roles/custom/matrix-base/tasks/util/ensure_openssl_installed_archlinux.yml @@ -0,0 +1,6 @@ +--- + +- name: Ensure openssl installed (Archlinux) + community.general.pacman: + name: openssl + state: present diff --git a/roles/custom/matrix-base/tasks/util/ensure_openssl_installed_debian.yml b/roles/custom/matrix-base/tasks/util/ensure_openssl_installed_debian.yml new file mode 100644 index 000000000..18f1cb95e --- /dev/null +++ b/roles/custom/matrix-base/tasks/util/ensure_openssl_installed_debian.yml @@ -0,0 +1,6 @@ +--- + +- name: Ensure openssl installed (Debian/Raspbian) + ansible.builtin.apt: + name: openssl + state: present diff --git a/roles/custom/matrix-base/tasks/util/ensure_openssl_installed_redhat.yml b/roles/custom/matrix-base/tasks/util/ensure_openssl_installed_redhat.yml new file mode 100644 index 000000000..b8809cf55 --- /dev/null +++ b/roles/custom/matrix-base/tasks/util/ensure_openssl_installed_redhat.yml @@ -0,0 +1,6 @@ +--- + +- name: Ensure openssl installed (RedHat) + ansible.builtin.yum: + name: openssl + state: present