From 3031e51778e95387e835fceb8d3ef655ce38708a Mon Sep 17 00:00:00 2001 From: =?utf8?q?S=C3=A9bastien=20Han?= Date: Tue, 12 Sep 2017 17:05:34 -0600 Subject: [PATCH] shrink-osd: fix when multiple osds MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit The loop was being built properly so we were always getting the last item as osd host. Closes: https://bugzilla.redhat.com/show_bug.cgi?id=1490355 Signed-off-by: Sébastien Han --- infrastructure-playbooks/shrink-osd.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/infrastructure-playbooks/shrink-osd.yml b/infrastructure-playbooks/shrink-osd.yml index 4fe579879..cc014df4c 100644 --- a/infrastructure-playbooks/shrink-osd.yml +++ b/infrastructure-playbooks/shrink-osd.yml @@ -50,7 +50,7 @@ - name: exit playbook, if no osd(s) was/were given fail: msg: "osd_to_kill must be declared - Exiting shrink-osd playbook, no OSD()s was/were removed. + Exiting shrink-osd playbook, no OSD(s) was/were removed. On the command line when invoking the playbook, you can use -e osd_to_kill=0,1,2,3 argument." when: osd_to_kill is not defined @@ -75,7 +75,7 @@ register: find_osd_hosts - set_fact: - osd_hosts: "{{ (item.stdout | from_json).crush_location.host }}" + osd_hosts: "{{ osd_hosts | default([]) + [ (item.stdout | from_json).crush_location.host ] }}" with_items: "{{ find_osd_hosts.results }}" - name: check if ceph admin key exists on the osd nodes @@ -96,6 +96,7 @@ command: ceph-disk deactivate --cluster {{ cluster }} --deactivate-by-id {{ item.0 }} --mark-out register: deactivate ignore_errors: yes + run_once: true with_together: - "{{ osd_to_kill.split(',') }}" - "{{ osd_hosts }}" @@ -114,6 +115,7 @@ command: ceph-disk destroy --cluster {{ cluster }} --destroy-by-id {{ item.0 }} --zap register: destroy ignore_errors: yes + run_once: true with_together: - "{{ osd_to_kill.split(',') }}" - "{{ osd_hosts }}" @@ -121,6 +123,7 @@ - name: remove osd(s) from crush_map when ceph-disk destroy fail command: ceph --cluster {{ cluster }} osd crush remove osd.{{ item.0 }} + run_once: true delegate_to: "{{ groups[mon_group_name][0] }}" with_together: - "{{ osd_to_kill.split(',') }}" -- 2.39.5