]> git.apps.os.sepia.ceph.com Git - ceph-ansible.git/commitdiff
enable prepare osd with partition devices in raw_multi_journal 1178/head
authorShengjing Zhu <zsj950618@gmail.com>
Wed, 30 Nov 2016 10:00:39 +0000 (18:00 +0800)
committerShengjing Zhu <zsj950618@gmail.com>
Thu, 15 Dec 2016 14:03:38 +0000 (22:03 +0800)
Address #895

Signed-off-by: Shengjing Zhu <zsj950618@gmail.com>
roles/ceph-osd/tasks/check_devices.yml
roles/ceph-osd/tasks/check_devices_static.yml
roles/ceph-osd/tasks/scenarios/raw_multi_journal.yml

index 5c8cb76ec322f4fd5faa5c5cb7323b8d3ab68daf..127a9c5fdabb3ff6918ba7ef0d80d197d54b83d2 100644 (file)
   # Hard code this so we will skip the entire file instead of individual tasks (Default isn't Consistent)
   static: False
 
+- name: check the journal device is partition
+  shell: "readlink -f {{ item }} | egrep '/dev/([hsv]d[a-z]{1,2}|cciss/c[0-9]d[0-9]p|nvme[0-9]n[0-9]p)[0-9]{1,2}$'"
+  with_items: "{{ raw_journal_devices }}"
+  changed_when: false
+  failed_when: false
+  always_run: true
+  register: journal_ispartition_results
+
 - name: check the partition status of the journal devices
-  shell: "parted --script {{ item }} print > /dev/null 2>&1"
-  with_items: "{{ raw_journal_devices|unique }}"
+  shell: "parted --script {{ item.1 }} print > /dev/null 2>&1"
+  with_together:
+    - "{{ journal_ispartition_results.results }}"
+    - "{{ raw_journal_devices|unique }}"
   changed_when: false
   failed_when: false
   always_run: true
   register: journal_partition_status
-  when: raw_multi_journal or dmcrypt_dedicated_journal
+  when:
+    - (raw_multi_journal or dmcrypt_dedicated_journal)
+    - item.0.rc != 0
 
 - name: fix partitions gpt header or labels of the journal devices
   shell: "sgdisk --zap-all --clear --mbrtogpt -- {{ item.1 }} || sgdisk --zap-all --clear --mbrtogpt -- {{ item.1 }}"
@@ -40,5 +52,6 @@
     - "{{ raw_journal_devices|unique }}"
   changed_when: false
   when:
-    - raw_multi_journal or dmcrypt_dedicated_journal
-    - item.0.rc != 0
+    - (raw_multi_journal or dmcrypt_dedicated_journal)
+    - not item.0.get("skipped")
+    - item.0.get("rc", 0) != 0
index bf301c29fdbde66974debae0c768f67f24ba0c16..e4a8c569bfb48f639a4009e4a9448eed2720c84f 100644 (file)
@@ -8,12 +8,15 @@
   register: ispartition_results
 
 - name: check the partition status of the osd disks
-  shell: "parted --script {{ item }} print > /dev/null 2>&1"
-  with_items: "{{ devices }}"
+  shell: "parted --script {{ item.1 }} print > /dev/null 2>&1"
+  with_together:
+    - "{{ ispartition_results.results }}"
+    - "{{ devices }}"
   changed_when: false
   failed_when: false
   always_run: true
   register: osd_partition_status_results
+  when: item.0.rc != 0
 
 # NOTE: The following calls to sgdisk are retried because sgdisk is known to
 # fully wipe a device the first time around. There is no need to halt execution
     - "{{ osd_partition_status_results.results }}"
     - "{{ devices }}"
   changed_when: false
-  when: item.0.rc != 0
+  when:
+    - not item.0.get("skipped")
+    - item.0.get("rc", 0) != 0
 
 - name: check if a partition named 'ceph' exists
-  shell: "parted --script {{ item }} print | egrep -sq '^ 1.*ceph'"
-  with_items: "{{ devices }}"
+  shell: "parted --script {{ item.1 }} print | egrep -sq '^ 1.*ceph'"
+  with_together:
+    - "{{ ispartition_results.results }}"
+    - "{{ devices }}"
   changed_when: false
   failed_when: false
   always_run: true
   register: parted_results
+  when: item.0.rc != 0
index e1c4fce8860b34de093814af524c6bb0407839a6..5321a3ede15668b54ac18cfd7a0ef3e52510e31b 100644 (file)
@@ -7,21 +7,15 @@
 # if you have 64 disks with 4TB each, this will take a while
 # since Ansible will sequential process the loop
 
-# NOTE (alahouze): if the device is a partition, the parted command below has
-# failed, this is why we check if the device is a partition too.
 - name: prepare osd disk(s)
-  command: "ceph-disk prepare --cluster {{ cluster }} {{ item.2 }} {{ item.3 }}"
+  command: "ceph-disk prepare --cluster {{ cluster }} {{ item.1 }} {{ item.2 }}"
   with_together:
     - "{{ parted_results.results }}"
-    - "{{ ispartition_results.results }}"
     - "{{ devices }}"
     - "{{ raw_journal_devices }}"
   changed_when: false
   when:
-    - not item.0.get("skipped")
-    - not item.1.get("skipped")
-    - item.0.get("rc", 0) != 0
-    - item.1.get("rc", 0) != 0
+    - item.0.get("skipped") or item.0.get("rc", 0) != 0
     - raw_multi_journal
     - not osd_auto_discovery