]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-ansible.git/commitdiff
purge: stop rgw instances by iteration
authorDimitri Savineau <dsavinea@redhat.com>
Fri, 31 Jan 2020 15:42:10 +0000 (10:42 -0500)
committerGuillaume Abrioux <gabrioux@redhat.com>
Mon, 2 Mar 2020 15:32:06 +0000 (16:32 +0100)
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 <dsavinea@redhat.com>
infrastructure-playbooks/purge-cluster.yml
infrastructure-playbooks/purge-container-cluster.yml
roles/ceph-facts/tasks/facts.yml
roles/ceph-facts/tasks/set_radosgw_address.yml
roles/ceph-rgw/handlers/main.yml

index 3bc8c8d49987e3c490378aa937d186bc9bc6f5b7..e98ce43e9949b2f657b82448700a6afde2b8fe0d 100644 (file)
   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
index 1a8475f656d6bf09db7affdea9ee2c10d4d0327d..972b50288a69ae82ff04fea77ac8b0ac267f1b31 100644 (file)
   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
index fdfc4f130de10f53c11aeedd9b0cd7d8a57267b3..939e08153c530709281b5a86e37ae57b1d2a4b32 100644 (file)
   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_fact use_new_ceph_iscsi package or old ceph-iscsi-config/cli
   set_fact:
     use_new_ceph_iscsi: "{{ (gateway_ip_list  == '0.0.0.0' and gateway_iqn | length == 0 and client_connections | length == 0 and rbd_devices | length == 0) | bool | ternary(true, false) }}"
index 3b1de111532f692c0e4ef5e489e51e473992dc82..28cb8d6ef4616d6a31211c9f1c9df2e5b4b0ad3e 100644 (file)
@@ -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 }}
index 803b9ec3ddb5ae5bc4063b9c4a72b1cfd1209e6c..08383e9087e28b33ccca6920fd1340a3f63f7844 100644 (file)
@@ -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 }}"