From e037e99bd279d9d38b4a9f27643d5eb124081fa3 Mon Sep 17 00:00:00 2001 From: Dimitri Savineau Date: Fri, 31 Jan 2020 10:42:10 -0500 Subject: [PATCH] purge: stop rgw instances by iteration It looks like that the service module doesn't support wildcard anymore for stopping/disabling multiple services. fatal: [rgw0]: FAILED! => changed=false msg: 'This module does not currently support using glob patterns, found ''*'' in service name: ceph-radosgw@*' ...ignoring Instead we should iterate over the rgw_instances list. Signed-off-by: Dimitri Savineau (cherry picked from commit 9d3b49293d785b9b2b6bb902bce0ae8bce6b4e6e) --- infrastructure-playbooks/purge-cluster.yml | 19 ++++++++----- .../purge-container-cluster.yml | 27 ++++++++++++------- roles/ceph-facts/tasks/facts.yml | 6 ----- .../ceph-facts/tasks/set_radosgw_address.yml | 5 ++++ roles/ceph-rgw/handlers/main.yml | 3 ++- 5 files changed, 37 insertions(+), 23 deletions(-) diff --git a/infrastructure-playbooks/purge-cluster.yml b/infrastructure-playbooks/purge-cluster.yml index e4e926778..4ce72b05f 100644 --- a/infrastructure-playbooks/purge-cluster.yml +++ b/infrastructure-playbooks/purge-cluster.yml @@ -296,13 +296,20 @@ become: true tasks: + - import_role: + name: ceph-defaults - - name: stop ceph rgws with systemd - service: - name: ceph-radosgw@rgw.* - state: stopped - enabled: no - failed_when: false + - import_role: + name: ceph-facts + tasks_from: set_radosgw_address + + - name: stop ceph rgws with systemd + service: + name: "ceph-radosgw@rgw.{{ ansible_hostname }}.{{ item.instance_name }}" + state: stopped + enabled: no + failed_when: false + with_items: "{{ rgw_instances }}" - name: purge ceph rbd-mirror cluster diff --git a/infrastructure-playbooks/purge-container-cluster.yml b/infrastructure-playbooks/purge-container-cluster.yml index 7fb19e783..4144c8ecc 100644 --- a/infrastructure-playbooks/purge-container-cluster.yml +++ b/infrastructure-playbooks/purge-container-cluster.yml @@ -193,18 +193,25 @@ become: true tasks: + - import_role: + name: ceph-defaults - - name: disable ceph rgw service - service: - name: "ceph-radosgw@*" - state: stopped - enabled: no - ignore_errors: true + - import_role: + name: ceph-facts + tasks_from: set_radosgw_address - - name: remove ceph rgw service - file: - path: /etc/systemd/system/ceph-radosgw@.service - state: absent + - name: disable ceph rgw service + service: + name: "ceph-radosgw@rgw.{{ ansible_hostname }}.{{ item.instance_name }}" + state: stopped + enabled: no + failed_when: false + with_items: "{{ rgw_instances }}" + + - name: remove ceph rgw service + file: + path: /etc/systemd/system/ceph-radosgw@.service + state: absent - name: purge ceph rbd-mirror cluster diff --git a/roles/ceph-facts/tasks/facts.yml b/roles/ceph-facts/tasks/facts.yml index 8d27812bb..eb81f588f 100644 --- a/roles/ceph-facts/tasks/facts.yml +++ b/roles/ceph-facts/tasks/facts.yml @@ -331,12 +331,6 @@ import_tasks: set_radosgw_address.yml when: inventory_hostname in groups.get(rgw_group_name, []) -- name: set_fact rgw_instances - set_fact: - rgw_instances: "{{ rgw_instances|default([]) | union([{'instance_name': 'rgw' + item|string, 'radosgw_address': _radosgw_address, 'radosgw_frontend_port': radosgw_frontend_port|int + item|int}]) }}" - with_sequence: start=0 end={{ radosgw_num_instances|int - 1 }} - when: inventory_hostname in groups.get(rgw_group_name, []) - - name: set ntp service name depending on OS family block: - name: set ntp service name for Debian family diff --git a/roles/ceph-facts/tasks/set_radosgw_address.yml b/roles/ceph-facts/tasks/set_radosgw_address.yml index 3b1de1115..28cb8d6ef 100644 --- a/roles/ceph-facts/tasks/set_radosgw_address.yml +++ b/roles/ceph-facts/tasks/set_radosgw_address.yml @@ -41,3 +41,8 @@ set_fact: _radosgw_address: "{{ hostvars[inventory_hostname][_interface][ip_version][0]['address'] }}" when: ip_version == 'ipv6' + +- name: set_fact rgw_instances + set_fact: + rgw_instances: "{{ rgw_instances|default([]) | union([{'instance_name': 'rgw' + item|string, 'radosgw_address': _radosgw_address, 'radosgw_frontend_port': radosgw_frontend_port|int + item|int}]) }}" + with_sequence: start=0 end={{ radosgw_num_instances|int - 1 }} diff --git a/roles/ceph-rgw/handlers/main.yml b/roles/ceph-rgw/handlers/main.yml index 803b9ec3d..08383e908 100644 --- a/roles/ceph-rgw/handlers/main.yml +++ b/roles/ceph-rgw/handlers/main.yml @@ -6,5 +6,6 @@ - name: restart rgw service: - name: ceph-radosgw@* + name: "ceph-radosgw@rgw.{{ ansible_hostname }}.{{ item.instance_name }}" state: restarted + with_items: "{{ rgw_instances }}"