From 0b9f322ca0f70b95101225dfe19e6f45ce25594f Mon Sep 17 00:00:00 2001 From: WingkaiHo Date: Thu, 27 Apr 2017 10:26:26 +0800 Subject: [PATCH] improve shrink-osd.yml can shrink osd when disk damage --- infrastructure-playbooks/shrink-osd.yml | 36 +++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/infrastructure-playbooks/shrink-osd.yml b/infrastructure-playbooks/shrink-osd.yml index e71e53178..3fc54ce78 100644 --- a/infrastructure-playbooks/shrink-osd.yml +++ b/infrastructure-playbooks/shrink-osd.yml @@ -118,14 +118,50 @@ - name: deactivating osd(s) command: ceph-disk deactivate --cluster {{ cluster }} --deactivate-by-id {{ item.0 }} --mark-out + register: deactivate + ignore_errors: yes with_together: - "{{ osd_ids.split(',') }}" - "{{ real_ips }}" delegate_to: "{{ item.1 }}" + - name: set osd(s) out when ceph-disk deactivating fail + command: ceph --cluster {{ cluster }} osd out osd.{{ item.0 }} + with_together: + - "{{ osd_ids.split(',') }}" + - "{{ deactivate.results }}" + when: + - item.1.stderr|length > 0 + - name: destroying osd(s) command: ceph-disk destroy --cluster {{ cluster }} --destroy-by-id {{ item.0 }} --zap + register: destroy + ignore_errors: yes with_together: - "{{ osd_ids.split(',') }}" - "{{ real_ips }}" delegate_to: "{{ item.1 }}" + + - name: remove osd(s) from crush_map when ceph-disk destroy fail + command: ceph --cluster {{ cluster }} osd crush remove osd.{{ item.0 }} + with_together: + - "{{ osd_ids.split(',') }}" + - "{{ destroy.results }}" + when: + - item.1.stderr|length > 0 + + - name: delete osd(s) auth key when ceph-disk destroy fail + command: ceph --cluster {{ cluster }} auth del osd.{{ item.0 }} + with_together: + - "{{ osd_ids.split(',') }}" + - "{{ destroy.results }}" + when: + - item.1.stderr|length > 0 + + - name: deallocate osd(s) id when ceph-disk destroy fail + command: ceph --cluster {{ cluster }} osd rm {{ item.0 }} + with_together: + - "{{ osd_ids.split(',') }}" + - "{{ destroy.results }}" + when: + - item.1.stderr|length > 0 -- 2.47.3