shrink-rbdmirror: check if rbdmirror is well removed from cluster

This commits adds a check to ensure the daemon has been removed from the
cluster.

Signed-off-by: Guillaume Abrioux <gabrioux@redhat.com>
(cherry picked from commit 916dc1f52f)
pull/4239/head
Guillaume Abrioux 2019-07-11 11:26:50 +02:00
parent 41a4ded2b5
commit bee8a31afe
1 changed files with 34 additions and 1 deletions

View File

@ -66,7 +66,7 @@
container_exec_cmd: "{{ container_binary }} exec ceph-mon-{{ hostvars[groups[mon_group_name][0]]['ansible_hostname'] }}" container_exec_cmd: "{{ container_binary }} exec ceph-mon-{{ hostvars[groups[mon_group_name][0]]['ansible_hostname'] }}"
- name: exit playbook, if can not connect to the cluster - name: exit playbook, if can not connect to the cluster
command: "{{ container_exec_cmd | default('') }} timeout 5 ceph --cluster {{ cluster }} health" command: "{{ container_exec_cmd | default('') }} timeout 5 ceph --cluster {{ cluster }} -s -f json"
register: ceph_health register: ceph_health
until: ceph_health.rc until: ceph_health.rc
failed_when: ceph_health.rc != 0 failed_when: ceph_health.rc != 0
@ -78,6 +78,18 @@
set_fact: set_fact:
rbdmirror_to_kill_hostname: "{{ hostvars[rbdmirror_to_kill]['ansible_hostname'] }}" rbdmirror_to_kill_hostname: "{{ hostvars[rbdmirror_to_kill]['ansible_hostname'] }}"
- name: set_fact rbdmirror_gids
set_fact:
rbdmirror_gids: "{{ rbdmirror_gids | default([]) + [ item ] }}"
with_items: "{{ (ceph_health.stdout | from_json)['servicemap']['services']['rbd-mirror']['daemons'].keys() | list }}"
when: item != 'summary'
- name: set_fact rbdmirror_to_kill_gid
set_fact:
rbdmirror_to_kill_gid: "{{ (ceph_health.stdout | from_json)['servicemap']['services']['rbd-mirror']['daemons'][item]['gid'] }}"
with_items: "{{ rbdmirror_gids }}"
when: (ceph_health.stdout | from_json)['servicemap']['services']['rbd-mirror']['daemons'][item]['metadata']['hostname'] == rbdmirror_to_kill_hostname
tasks: tasks:
- name: stop rbdmirror service - name: stop rbdmirror service
service: service:
@ -94,6 +106,27 @@
delegate_to: "{{ rbdmirror_to_kill }}" delegate_to: "{{ rbdmirror_to_kill }}"
post_tasks: post_tasks:
- name: get servicemap details
command: "{{ container_exec_cmd | default('') }} timeout 5 ceph --cluster {{ cluster }} -s -f json"
register: ceph_health
delegate_to: "{{ groups[mon_group_name][0] }}"
- name: set_fact rbdmirror_gids
set_fact:
post_rbdmirror_gids: "{{ post_rbdmirror_gids | default([]) + [ item ] }}"
with_items: "{{ (ceph_health.stdout | from_json)['servicemap']['services']['rbd-mirror']['daemons'].keys() | list }}"
when:
- "'rbd-mirror' in (ceph_health.stdout | from_json)['servicemap']['services'].keys() | list"
- item != 'summary'
- name: show ceph health - name: show ceph health
command: "{{ container_exec_cmd | default('') }} ceph --cluster {{ cluster }} -s" command: "{{ container_exec_cmd | default('') }} ceph --cluster {{ cluster }} -s"
delegate_to: "{{ groups[mon_group_name][0] }}" delegate_to: "{{ groups[mon_group_name][0] }}"
- name: check presence of "{{ rbdmirror_to_kill_hostname }}"
fail:
msg: "{{ rbdmirror_to_kill_hostname }} still active!"
when:
- rbdmirror_to_kill_gid is defined
- post_rbdmirror_gids is defined
- rbdmirror_to_kill_gid in post_rbdmirror_gids