From bab034024c7dfdbce25531963c162dd94e4f394d Mon Sep 17 00:00:00 2001 From: Guillaume Abrioux Date: Thu, 14 Mar 2024 21:39:45 +0100 Subject: [PATCH] handlers: move tmpdir removal This moves the tmpdir removal tasks to main playbook. The handlers in Ansible are too restrictive and doesn't work quite well for our use case. Signed-off-by: Guillaume Abrioux --- roles/ceph-handler/handlers/main.yml | 23 ---------------------- site-container.yml.sample | 29 ++++++++++++++++++++++++++++ site.yml.sample | 28 +++++++++++++++++++++++++++ 3 files changed, 57 insertions(+), 23 deletions(-) diff --git a/roles/ceph-handler/handlers/main.yml b/roles/ceph-handler/handlers/main.yml index 5f61afe3b..440918c21 100644 --- a/roles/ceph-handler/handlers/main.yml +++ b/roles/ceph-handler/handlers/main.yml @@ -69,26 +69,3 @@ or inventory_hostname in groups.get(mds_group_name, []) or inventory_hostname in groups.get(rgw_group_name, []) or inventory_hostname in groups.get(rbdmirror_group_name, []) - - - name: Remove tempdir for scripts - ansible.builtin.file: - path: "{{ tmpdirpath.path }}" - state: absent - listen: - - "Restart ceph mons" - - "Restart ceph osds" - - "Restart ceph mdss" - - "Restart ceph rgws" - - "Restart ceph rbdmirrors" - - "Restart ceph mgrs" - register: tmpdirpath - when: - - tmpdirpath.path is defined - - not _exporter_handler_called | default(false) | bool - - not _crash_handler_called | default(false) | bool - - not _mds_handler_called | default(false) | bool - - not _mgr_handler_called | default(false) | bool - - not _mon_handler_called | default(false) | bool - - not _osd_handler_called | default(false) | bool - - not _rbdmirror_handler_called | default(false) | bool - - not _rgw_handler_called | default(false) | bool diff --git a/site-container.yml.sample b/site-container.yml.sample index 08c317500..0c8de0e0a 100644 --- a/site-container.yml.sample +++ b/site-container.yml.sample @@ -469,6 +469,35 @@ status: "Complete" end: "{{ lookup('pipe', 'date +%Y%m%d%H%M%SZ') }}" +- hosts: + - mons + - osds + - mdss + - rgws + - rbdmirrors + - clients + - mgrs + - monitoring + gather_facts: false + become: True + any_errors_fatal: true + tasks: + - name: Remove tempdir for scripts + ansible.builtin.file: + path: "{{ tmpdirpath.path }}" + state: absent + when: + - tmpdirpath.path is defined + - not _exporter_handler_called | default(false) | bool + - not _crash_handler_called | default(false) | bool + - not _mds_handler_called | default(false) | bool + - not _mgr_handler_called | default(false) | bool + - not _mon_handler_called | default(false) | bool + - not _osd_handler_called | default(false) | bool + - not _rbdmirror_handler_called | default(false) | bool + - not _rgw_handler_called | default(false) | bool + + - hosts: mons[0] gather_facts: false become: True diff --git a/site.yml.sample b/site.yml.sample index fd67deba6..ef1234bc5 100644 --- a/site.yml.sample +++ b/site.yml.sample @@ -451,6 +451,34 @@ status: "Complete" end: "{{ lookup('pipe', 'date +%Y%m%d%H%M%SZ') }}" +- hosts: + - mons + - osds + - mdss + - rgws + - rbdmirrors + - clients + - mgrs + - monitoring + gather_facts: false + become: True + any_errors_fatal: true + tasks: + - name: Remove tempdir for scripts + ansible.builtin.file: + path: "{{ tmpdirpath.path }}" + state: absent + when: + - tmpdirpath.path is defined + - not _exporter_handler_called | default(false) | bool + - not _crash_handler_called | default(false) | bool + - not _mds_handler_called | default(false) | bool + - not _mgr_handler_called | default(false) | bool + - not _mon_handler_called | default(false) | bool + - not _osd_handler_called | default(false) | bool + - not _rbdmirror_handler_called | default(false) | bool + - not _rgw_handler_called | default(false) | bool + - hosts: mons gather_facts: false become: True