From 2473cd655b15791d4942ec2c473fbd9acdb0c508 Mon Sep 17 00:00:00 2001 From: Slavi Pantaleev Date: Sat, 5 Nov 2022 09:15:35 +0200 Subject: [PATCH] Include ensure_openssl_installed and ensure_fuse_installed utils in a more reliable way This fixes a regression since the change done in c1c152f7acb931021acb3. When another role (say `matrix-jitsi`) included `roles/custom/matrix-base/tasks/util/ensure_openssl_installed.yml`, which then included `{{ role_path }}/tasks/util/ensure_openssl_installed_DISTRO.yml`, that `role_path` variable would end up being the parent role (`matrix-jitsi`) and not the `matrix-base` role, so we'd get a failure. An alternative solution may have been to avoid using `role_path`, but importing roles properly (like we've done in this patch) sounds like a better way. Unfortunately, `import_role` fails if `tasks_from` is something like `util/ensure_openssl_installed` (containing a `/`), so I had to move these utils out of `util/`. Related to https://github.com/spantaleev/matrix-docker-ansible-deploy/issues/2228 --- .../matrix-base/tasks/ensure_fuse_installed.yml | 12 ++++++++++++ .../{util => }/ensure_fuse_installed_archlinux.yml | 0 .../{util => }/ensure_fuse_installed_debian.yml | 0 .../{util => }/ensure_fuse_installed_redhat.yml | 0 .../matrix-base/tasks/ensure_openssl_installed.yml | 12 ++++++++++++ .../ensure_openssl_installed_archlinux.yml | 0 .../{util => }/ensure_openssl_installed_debian.yml | 0 .../{util => }/ensure_openssl_installed_redhat.yml | 0 .../matrix-base/tasks/util/ensure_fuse_installed.yml | 12 ------------ .../tasks/util/ensure_openssl_installed.yml | 12 ------------ .../tasks/setup_install.yml | 4 +++- .../matrix-bridge-hookshot/tasks/setup_install.yml | 4 +++- roles/custom/matrix-jitsi/tasks/setup_jitsi_base.yml | 4 +++- .../tasks/ssl/setup_ssl_self_signed.yml | 4 +++- .../matrix-synapse/tasks/goofys/setup_install.yml | 4 +++- 15 files changed, 39 insertions(+), 29 deletions(-) create mode 100644 roles/custom/matrix-base/tasks/ensure_fuse_installed.yml rename roles/custom/matrix-base/tasks/{util => }/ensure_fuse_installed_archlinux.yml (100%) rename roles/custom/matrix-base/tasks/{util => }/ensure_fuse_installed_debian.yml (100%) rename roles/custom/matrix-base/tasks/{util => }/ensure_fuse_installed_redhat.yml (100%) create mode 100644 roles/custom/matrix-base/tasks/ensure_openssl_installed.yml rename roles/custom/matrix-base/tasks/{util => }/ensure_openssl_installed_archlinux.yml (100%) rename roles/custom/matrix-base/tasks/{util => }/ensure_openssl_installed_debian.yml (100%) rename roles/custom/matrix-base/tasks/{util => }/ensure_openssl_installed_redhat.yml (100%) delete mode 100644 roles/custom/matrix-base/tasks/util/ensure_fuse_installed.yml delete mode 100644 roles/custom/matrix-base/tasks/util/ensure_openssl_installed.yml diff --git a/roles/custom/matrix-base/tasks/ensure_fuse_installed.yml b/roles/custom/matrix-base/tasks/ensure_fuse_installed.yml new file mode 100644 index 00000000..8f768bd1 --- /dev/null +++ b/roles/custom/matrix-base/tasks/ensure_fuse_installed.yml @@ -0,0 +1,12 @@ +--- + +# This is for both RedHat 7 and 8 +- ansible.builtin.include_tasks: "{{ role_path }}/tasks/ensure_fuse_installed_redhat.yml" + when: ansible_os_family == 'RedHat' + +# This is for both Debian and Raspbian +- ansible.builtin.include_tasks: "{{ role_path }}/tasks/ensure_fuse_installed_debian.yml" + when: ansible_os_family == 'Debian' + +- ansible.builtin.include_tasks: "{{ role_path }}/tasks/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/ensure_fuse_installed_archlinux.yml similarity index 100% rename from roles/custom/matrix-base/tasks/util/ensure_fuse_installed_archlinux.yml rename to roles/custom/matrix-base/tasks/ensure_fuse_installed_archlinux.yml diff --git a/roles/custom/matrix-base/tasks/util/ensure_fuse_installed_debian.yml b/roles/custom/matrix-base/tasks/ensure_fuse_installed_debian.yml similarity index 100% rename from roles/custom/matrix-base/tasks/util/ensure_fuse_installed_debian.yml rename to roles/custom/matrix-base/tasks/ensure_fuse_installed_debian.yml diff --git a/roles/custom/matrix-base/tasks/util/ensure_fuse_installed_redhat.yml b/roles/custom/matrix-base/tasks/ensure_fuse_installed_redhat.yml similarity index 100% rename from roles/custom/matrix-base/tasks/util/ensure_fuse_installed_redhat.yml rename to roles/custom/matrix-base/tasks/ensure_fuse_installed_redhat.yml diff --git a/roles/custom/matrix-base/tasks/ensure_openssl_installed.yml b/roles/custom/matrix-base/tasks/ensure_openssl_installed.yml new file mode 100644 index 00000000..889531f9 --- /dev/null +++ b/roles/custom/matrix-base/tasks/ensure_openssl_installed.yml @@ -0,0 +1,12 @@ +--- + +# This is for both RedHat 7 and 8 +- ansible.builtin.include_tasks: "{{ role_path }}/tasks/ensure_openssl_installed_redhat.yml" + when: ansible_os_family == 'RedHat' + +# This is for both Debian and Raspbian +- ansible.builtin.include_tasks: "{{ role_path }}/tasks/ensure_openssl_installed_debian.yml" + when: ansible_os_family == 'Debian' + +- ansible.builtin.include_tasks: "{{ role_path }}/tasks/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/ensure_openssl_installed_archlinux.yml similarity index 100% rename from roles/custom/matrix-base/tasks/util/ensure_openssl_installed_archlinux.yml rename to roles/custom/matrix-base/tasks/ensure_openssl_installed_archlinux.yml diff --git a/roles/custom/matrix-base/tasks/util/ensure_openssl_installed_debian.yml b/roles/custom/matrix-base/tasks/ensure_openssl_installed_debian.yml similarity index 100% rename from roles/custom/matrix-base/tasks/util/ensure_openssl_installed_debian.yml rename to roles/custom/matrix-base/tasks/ensure_openssl_installed_debian.yml diff --git a/roles/custom/matrix-base/tasks/util/ensure_openssl_installed_redhat.yml b/roles/custom/matrix-base/tasks/ensure_openssl_installed_redhat.yml similarity index 100% rename from roles/custom/matrix-base/tasks/util/ensure_openssl_installed_redhat.yml rename to roles/custom/matrix-base/tasks/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 deleted file mode 100644 index a23c77e1..00000000 --- a/roles/custom/matrix-base/tasks/util/ensure_fuse_installed.yml +++ /dev/null @@ -1,12 +0,0 @@ ---- - -# This is for both RedHat 7 and 8 -- 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 -- ansible.builtin.include_tasks: "{{ role_path }}/tasks/util/ensure_fuse_installed_debian.yml" - when: ansible_os_family == 'Debian' - -- 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_openssl_installed.yml b/roles/custom/matrix-base/tasks/util/ensure_openssl_installed.yml deleted file mode 100644 index a3b73d68..00000000 --- a/roles/custom/matrix-base/tasks/util/ensure_openssl_installed.yml +++ /dev/null @@ -1,12 +0,0 @@ ---- - -# This is for both RedHat 7 and 8 -- 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 -- ansible.builtin.include_tasks: "{{ role_path }}/tasks/util/ensure_openssl_installed_debian.yml" - when: ansible_os_family == 'Debian' - -- ansible.builtin.include_tasks: "{{ role_path }}/tasks/util/ensure_openssl_installed_archlinux.yml" - when: ansible_os_family == 'Archlinux' diff --git a/roles/custom/matrix-bridge-appservice-irc/tasks/setup_install.yml b/roles/custom/matrix-bridge-appservice-irc/tasks/setup_install.yml index 468dbd7a..32d87408 100644 --- a/roles/custom/matrix-bridge-appservice-irc/tasks/setup_install.yml +++ b/roles/custom/matrix-bridge-appservice-irc/tasks/setup_install.yml @@ -1,6 +1,8 @@ --- -- ansible.builtin.import_tasks: "{{ role_path }}/../matrix-base/tasks/util/ensure_openssl_installed.yml" +- ansible.builtin.import_role: + name: custom/matrix-base + tasks_from: ensure_openssl_installed - name: Ensure Appservice IRC paths exist ansible.builtin.file: diff --git a/roles/custom/matrix-bridge-hookshot/tasks/setup_install.yml b/roles/custom/matrix-bridge-hookshot/tasks/setup_install.yml index 15209d2c..e13af198 100644 --- a/roles/custom/matrix-bridge-hookshot/tasks/setup_install.yml +++ b/roles/custom/matrix-bridge-hookshot/tasks/setup_install.yml @@ -1,6 +1,8 @@ --- -- ansible.builtin.import_tasks: "{{ role_path }}/../matrix-base/tasks/util/ensure_openssl_installed.yml" +- ansible.builtin.import_role: + name: custom/matrix-base + tasks_from: ensure_openssl_installed - name: Ensure hookshot paths exist ansible.builtin.file: diff --git a/roles/custom/matrix-jitsi/tasks/setup_jitsi_base.yml b/roles/custom/matrix-jitsi/tasks/setup_jitsi_base.yml index a91949e1..c52c1902 100644 --- a/roles/custom/matrix-jitsi/tasks/setup_jitsi_base.yml +++ b/roles/custom/matrix-jitsi/tasks/setup_jitsi_base.yml @@ -1,6 +1,8 @@ --- -- ansible.builtin.import_tasks: "{{ role_path }}/../matrix-base/tasks/util/ensure_openssl_installed.yml" +- ansible.builtin.import_role: + name: custom/matrix-base + tasks_from: ensure_openssl_installed # # Tasks related to setting up jitsi diff --git a/roles/custom/matrix-nginx-proxy/tasks/ssl/setup_ssl_self_signed.yml b/roles/custom/matrix-nginx-proxy/tasks/ssl/setup_ssl_self_signed.yml index 918b74db..7ebdec79 100644 --- a/roles/custom/matrix-nginx-proxy/tasks/ssl/setup_ssl_self_signed.yml +++ b/roles/custom/matrix-nginx-proxy/tasks/ssl/setup_ssl_self_signed.yml @@ -1,6 +1,8 @@ --- -- ansible.builtin.import_tasks: "{{ role_path }}/../matrix-base/tasks/util/ensure_openssl_installed.yml" +- ansible.builtin.import_role: + name: custom/matrix-base + tasks_from: ensure_openssl_installed when: "matrix_ssl_retrieval_method == 'self-signed'" - name: Generate self-signed certificates diff --git a/roles/custom/matrix-synapse/tasks/goofys/setup_install.yml b/roles/custom/matrix-synapse/tasks/goofys/setup_install.yml index 7eb7e46c..7649beb4 100644 --- a/roles/custom/matrix-synapse/tasks/goofys/setup_install.yml +++ b/roles/custom/matrix-synapse/tasks/goofys/setup_install.yml @@ -1,6 +1,8 @@ --- -- ansible.builtin.import_tasks: "{{ role_path }}/../matrix-base/tasks/util/ensure_fuse_installed.yml" +- ansible.builtin.import_role: + name: custom/matrix-base + tasks_from: ensure_fuse_installed - name: Ensure Goofys Docker image is pulled community.docker.docker_image: