]> git.apps.os.sepia.ceph.com Git - ceph-ansible.git/commitdiff
ceph-config: fix ceph-volume lvm batch report
authorDimitri Savineau <dsavinea@redhat.com>
Tue, 15 Dec 2020 18:52:43 +0000 (13:52 -0500)
committerDimitri Savineau <savineau.dimitri@gmail.com>
Tue, 15 Dec 2020 22:25:49 +0000 (17:25 -0500)
Since the major ceph-volume lvm batch refactoring, the report value
is different.
Before the refact, the report was a dict with the OSDs list to be created
under the "osds" key.
After the refact, the report is a list of dict.

Signed-off-by: Dimitri Savineau <dsavinea@redhat.com>
(cherry picked from commit 827b23353ff389660f393cb36fb36540c362e8cf)

roles/ceph-config/tasks/main.yml

index ef16fc317ec1004c5ed53b815f0f7a8ae1b56e31..98172c93a3afa73e0a048d1364a3e34449c4108e 100644 (file)
           CEPH_CONTAINER_BINARY: "{{ container_binary }}"
           PYTHONIOENCODING: utf-8
         when: _devices | default([]) | length > 0
-    when:
-      - devices | default([]) | length > 0
 
-  - name: set_fact num_osds from the output of 'ceph-volume lvm batch --report'
-    set_fact:
-      num_osds: "{{ ((lvm_batch_report.stdout | default('{}') | from_json).osds | default([]) | length | int) + (_rejected_devices | default([]) | length | int) }}"
+      - name: set_fact num_osds from the output of 'ceph-volume lvm batch --report' (legacy report)
+        set_fact:
+          num_osds: "{{ ((lvm_batch_report.stdout | default('{}') | from_json).osds | default([]) | length | int) + (_rejected_devices | default([]) | length | int) }}"
+        when:
+          - (lvm_batch_report.stdout | default('{}') | from_json) is mapping
+          - (lvm_batch_report.stdout | default('{}') | from_json).changed | default(true) | bool
+
+      - name: set_fact num_osds from the output of 'ceph-volume lvm batch --report' (new report)
+        set_fact:
+          num_osds: "{{ ((lvm_batch_report.stdout | default('{}') | from_json) | default([]) | length | int) + (_rejected_devices | default([]) | length | int) }}"
+        when:
+          - (lvm_batch_report.stdout | default('{}') | from_json) is not mapping
+          - (lvm_batch_report.stdout | default('{}') | from_json).changed | default(true) | bool
     when:
       - devices | default([]) | length > 0
-      - (lvm_batch_report.stdout | default('{}') | from_json).changed | default(true) | bool
 
   - name: run 'ceph-volume lvm list' to see how many osds have already been created
     ceph_volume: