]> git.apps.os.sepia.ceph.com Git - ceph-ansible.git/commitdiff
fs2bs: fix wrong filter when setting osd_ids
authorGuillaume Abrioux <gabrioux@redhat.com>
Tue, 25 May 2021 14:01:27 +0000 (16:01 +0200)
committerGuillaume Abrioux <gabrioux@redhat.com>
Tue, 25 May 2021 18:50:10 +0000 (20:50 +0200)
using 'match' filter in that task will lead to bad behavior if I have
the following node names for instance:

- node1
- node11
- node111

with `selectattr('name', 'match', inventory_hostname)` it will match
'node1' along with 'node11' and 'node111'.

using 'equalto' filter will make sure we only match the target node.

Closes: https://bugzilla.redhat.com/show_bug.cgi?id=1963066
Signed-off-by: Guillaume Abrioux <gabrioux@redhat.com>
(cherry picked from commit 0990ae41099d8b9d678f546fc8790033f421711f)

infrastructure-playbooks/filestore-to-bluestore.yml

index 87b32282b674e046e2069b20000274d13d0b0c27..c762653c3c2e85e942fad2cfcbe6179f3fda7442 100644 (file)
@@ -48,7 +48,7 @@
       set_fact:
         osd_ids: "{{ osd_ids | default([]) | union(item) }}"
       with_items:
-        - "{{ ((osd_tree.stdout | default('{}') | trim | from_json).nodes | selectattr('name', 'match', '^' + inventory_hostname + '$') | map(attribute='children') | list) }}"
+        - "{{ ((osd_tree.stdout | default('{}') | trim | from_json).nodes | selectattr('name', 'equalto', inventory_hostname) | map(attribute='children') | list) }}"
 
     - name: get osd metadata
       command: "{{ ceph_cmd }} --cluster {{ cluster }} osd metadata osd.{{ item }} -f json"
           set_fact:
             osd_ids: "{{ osd_ids | default([]) + [item] }}"
           with_items:
-            - "{{ ((osd_tree.stdout | default('{}') | from_json).nodes | selectattr('name', 'match', inventory_hostname) | map(attribute='children') | list) }}"
+            - "{{ ((osd_tree.stdout | default('{}') | from_json).nodes | selectattr('name', 'equalto', inventory_hostname) | map(attribute='children') | list) }}"
 
         - name: purge osd(s) from the cluster
           ceph_osd: