]> git.apps.os.sepia.ceph.com Git - ceph-ansible.git/commitdiff
Allow devices to be partition instead of disks (used for some physical servers with...
authorAlexis Lahouze <xals@lahouze.org>
Thu, 26 Jun 2014 12:19:09 +0000 (14:19 +0200)
committerAlexis Lahouze <xals@lahouze.org>
Thu, 26 Jun 2014 12:19:09 +0000 (14:19 +0200)
roles/osd/tasks/journal_collocation.yml
roles/osd/tasks/raw_journal.yml
roles/osd/tasks/raw_multi_journal.yml

index 21dee327f5de823d1b5453b07b16bcf1e1453bc4..566e1518764c87bb2515c6db8b4061111296c585 100644 (file)
 # I believe it's safer
 #
 
+- name: Check if device is a partition or a disk
+  shell: echo '{{ item }}' | egrep '/dev/[a-z]{3}[0-9]$'
+  ignore_errors: true
+  with_items: devices
+  register: ispartition
+  changed_when: False
+
 - name: If partition named 'ceph' exists
   shell: parted --script {{ item }} print | egrep -sq '^ 1.*ceph'
   ignore_errors: True
@@ -29,9 +36,9 @@
   changed_when: False
 
 # Prepare means
-# - create GPT partition
+# - create GPT partition for a disk, or a loop label for a partition
 # - mark the partition with the ceph type uuid
-# - create a file system
+# - create a XFS file system
 # - mark the fs as ready for ceph consumption
 # - entire data disk is used (one big partition)
 # - a new partition is added to the journal disk (so it can be easily shared)
 # 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 {{ item.1 }}
-  when: item.0.rc != 0 and journal_collocation
+  command: ceph-disk prepare {{ item.2 }}
+  when: (item.0.rc != 0 or item.1.rc != 0) and journal_collocation
   ignore_errors: True
   with_together:
     - parted.results
+    - ispartition.results
     - devices
 
 # Activate means:
 # - start ceph-osd
 #
 
-- name: Activate OSD(s)
-  command: ceph-disk activate {{ item }}1
-  with_items: devices
+# This task if for disk device only because of the explicit use of the first
+# partition.
+
+- name: Activate OSD(s) when device is a disk
+  command: ceph-disk activate {{ item.2 }}1
+  with_together:
+    - parted.results
+    - ispartition.results
+    - devices
+  when: item.0.rc == 0 and item.1.rc != 0
+  ignore_errors: True
+  changed_when: False
+
+# This task is for partitions because we don't explicitly use a partition.
+
+- name: Activate OSD(s) when device is a partition
+  command: ceph-disk activate {{ item.1 }}
+  with_together:
+    - ispartition.results
+    - devices
+  when: item.0.rc == 0
   ignore_errors: True
   changed_when: False
 
index f719ef74c55ca386238fe67342bd18b133456586..099715eb537debc8d775f1a19f7815eece30c84b 100644 (file)
 # I believe it's safer
 #
 
+- name: Check if device is a partition or a disk
+  shell: echo '{{ item }}' | egrep '/dev/[a-z]{3}[0-9]$'
+  ignore_errors: true
+  with_items: devices
+  register: ispartition
+  changed_when: False
+
 - name: If partition named 'ceph' exists
   shell: parted --script {{ item }} print | egrep -sq '^ 1.*ceph'
   ignore_errors: True
@@ -29,9 +36,9 @@
   changed_when: False
 
 # Prepare means
-# - create GPT partition
+# - create GPT partition for a disk, or a loop label for a partition
 # - mark the partition with the ceph type uuid
-# - create a file system
+# - create a XFS file system
 # - mark the fs as ready for ceph consumption
 # - entire data disk is used (one big partition)
 # - a new partition is added to the journal disk (so it can be easily shared)
 # 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 {{ item.1 }} {{ raw_journal_device }}
-  when: item.0.rc != 0 and raw_journal
+  command: ceph-disk prepare {{ item.2 }} {{ raw_journal_device }}
+  when: (item.0.rc != 0 or item.1.rc != 0) and raw_journal
   ignore_errors: True
   with_together:
     - parted.results
+    - ispartition.results
     - devices
 
 # Activate means:
 # - start ceph-osd
 #
 
-- name: Activate OSD(s)
-  command: ceph-disk activate {{ item }}1
-  with_items: devices
+# This task if for disk device only because of the explicit use of the first
+# partition.
+
+- name: Activate OSD(s) when device is a disk
+  command: ceph-disk activate {{ item.2 }}1
+  with_together:
+    - parted.results
+    - ispartition.results
+    - devices
+  when: item.0.rc == 0 and item.1.rc != 0
+  ignore_errors: True
+  changed_when: False
+
+# This task is for partitions because we don't explicitly use a partition.
+
+- name: Activate OSD(s) when device is a partition
+  command: ceph-disk activate {{ item.1 }}
+  with_together:
+    - ispartition.results
+    - devices
+  when: item.0.rc == 0
   ignore_errors: True
   changed_when: False
 
index aefeb3702fcf2a6202625c65561d2ce24db52f64..64744180eadc1f76632ae81f8c55565e16ac3a6c 100644 (file)
 # I believe it's safer
 #
 
+- name: Check if device is a partition or a disk
+  shell: echo '{{ item }}' | egrep '/dev/[a-z]{3}[0-9]$'
+  ignore_errors: true
+  with_items: devices
+  register: ispartition
+  changed_when: False
+
 - name: If partition named 'ceph' exists
   shell: parted --script {{ item }} print | egrep -sq '^ 1.*ceph'
   ignore_errors: True
@@ -29,9 +36,9 @@
   changed_when: False
 
 # Prepare means
-# - create GPT partition
+# - create GPT partition for a disk, or a loop label for a partition
 # - mark the partition with the ceph type uuid
-# - create a file system
+# - create a XFS file system
 # - mark the fs as ready for ceph consumption
 # - entire data disk is used (one big partition)
 # - a new partition is added to the journal disk (so it can be easily shared)
 # 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 {{ item.1 }} {{ item.2 }}
-  when: item.0.rc != 0 and raw_multi_journal
+  command: ceph-disk prepare {{ item.2 }} {{ item.3 }}
+  when: (item.0.rc != 0 or item.1.rc != 0) and raw_multi_journal
   ignore_errors: True
   with_together:
     - parted.results
+    - ispartition.results
     - devices
     - raw_journal_devices
 
 # - start ceph-osd
 #
 
-- name: Activate OSD(s)
-  command: ceph-disk activate {{ item }}1
-  with_items: devices
+# This task if for disk device only because of the explicit use of the first
+# partition.
+
+- name: Activate OSD(s) when device is a disk
+  command: ceph-disk activate {{ item.2 }}1
+  with_together:
+    - parted.results
+    - ispartition.results
+    - devices
+  when: item.0.rc == 0 and item.1.rc != 0
+  ignore_errors: True
+  changed_when: False
+
+# This task is for partitions because we don't explicitly use a partition.
+
+- name: Activate OSD(s) when device is a partition
+  command: ceph-disk activate {{ item.1 }}
+  with_together:
+    - ispartition.results
+    - devices
+  when: item.0.rc == 0
   ignore_errors: True
   changed_when: False