osd: refact 'wait for all osd to be up' task

let's use `until` instead of doing test in bash using python oneliner
also, use `command` instead of `shell`.

Signed-off-by: Guillaume Abrioux <gabrioux@redhat.com>
(cherry picked from commit c76cd5ad84)
pull/4531/head
Guillaume Abrioux 2019-08-14 10:47:40 +02:00
parent 86c224e71d
commit 8a1bda6d91
1 changed files with 4 additions and 5 deletions

View File

@ -1,15 +1,14 @@
--- ---
- name: wait for all osd to be up - name: wait for all osd to be up
shell: > command: "{{ container_exec_cmd | default('') }} ceph --cluster {{ cluster }} -s -f json"
test "$({{ hostvars[groups[mon_group_name][0]]['docker_exec_cmd'] | default('') }} ceph --cluster {{ cluster }} -s -f json | python -c 'import sys, json; print(json.load(sys.stdin)["osdmap"]["osdmap"]["num_osds"])')" -gt 0 &&
test "$({{ hostvars[groups[mon_group_name][0]]['docker_exec_cmd'] | default('') }} ceph --cluster {{ cluster }} -s -f json | python -c 'import sys, json; print(json.load(sys.stdin)["osdmap"]["osdmap"]["num_osds"])')" =
"$({{ hostvars[groups[mon_group_name][0]]['docker_exec_cmd'] | default('') }} ceph --cluster {{ cluster }} -s -f json | python -c 'import sys, json; print(json.load(sys.stdin)["osdmap"]["osdmap"]["num_up_osds"])')"
register: wait_for_all_osds_up register: wait_for_all_osds_up
retries: "{{ nb_retry_wait_osd_up }}" retries: "{{ nb_retry_wait_osd_up }}"
delay: "{{ delay_wait_osd_up }}" delay: "{{ delay_wait_osd_up }}"
changed_when: false changed_when: false
delegate_to: "{{ groups[mon_group_name][0] }}" delegate_to: "{{ groups[mon_group_name][0] }}"
until: wait_for_all_osds_up.rc == 0 until:
- (wait_for_all_osds_up.stdout | from_json)["osdmap"]["osdmap"]["num_osds"] | int > 0
- (wait_for_all_osds_up.stdout | from_json)["osdmap"]["osdmap"]["num_osds"] == (wait_for_all_osds_up.stdout | from_json)["osdmap"]["osdmap"]["num_up_osds"]
- name: pool related tasks - name: pool related tasks
block: block: