shrink-mon: refact 'verify the monitor is out of the cluster' task

use `from_json` filter instead of a `| python` so we can get rid of the
`shell` module usage here.

Signed-off-by: Guillaume Abrioux <gabrioux@redhat.com>
pull/4344/head
Guillaume Abrioux 2019-08-14 11:04:30 +02:00
parent 687087fd43
commit 5573f17e76
1 changed files with 2 additions and 7 deletions

View File

@ -110,17 +110,12 @@
delegate_to: "{{ mon_host }}" delegate_to: "{{ mon_host }}"
post_tasks: post_tasks:
# NOTE (leseb): sorry for the 'sleep' command
# but it will take a couple of seconds for other monitors
# to notice that one member has left.
# 'sleep 5' is not that bad and should be sufficient
- name: verify the monitor is out of the cluster - name: verify the monitor is out of the cluster
shell: | command: "{{ container_exec_cmd }} ceph --cluster {{ cluster }} -s -f json"
{{ container_exec_cmd }} ceph --cluster {{ cluster }} -s -f json | {{ discovered_interpreter_python }} -c 'import sys, json; print(json.load(sys.stdin)["quorum_names"])'
delegate_to: "{{ mon_host }}" delegate_to: "{{ mon_host }}"
failed_when: false failed_when: false
register: result register: result
until: mon_to_kill_hostname not in result.stdout until: mon_to_kill_hostname not in (result.stdout | from_json)['quorum_names']
retries: 2 retries: 2
delay: 10 delay: 10