]> git.apps.os.sepia.ceph.com Git - ceph-ansible.git/commitdiff
osd: refact 'wait for all osd to be up' task
authorGuillaume Abrioux <gabrioux@redhat.com>
Wed, 14 Aug 2019 08:47:40 +0000 (10:47 +0200)
committerGuillaume Abrioux <gabrioux@redhat.com>
Fri, 4 Oct 2019 02:25:20 +0000 (04:25 +0200)
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 c76cd5ad844b71a41d898febafda326ad067cc05)

roles/ceph-osd/tasks/openstack_config.yml

index ad0f59e045a242ef71de599a2c31e922012131e4..071dc67e45908c2155ccb7dc44835a9c8cbc1856 100644 (file)
@@ -1,15 +1,14 @@
 ---
 - name: wait for all osd to be up
-  shell: >
-    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"])')"
+  command: "{{ container_exec_cmd | default('') }} ceph --cluster {{ cluster }} -s -f json"
   register: wait_for_all_osds_up
   retries: "{{ nb_retry_wait_osd_up }}"
   delay: "{{ delay_wait_osd_up }}"
   changed_when: false
   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
   block: