]> git.apps.os.sepia.ceph.com Git - ceph-ansible.git/commitdiff
Zap disk before running ceph-disk prepare 158/head
authorSébastien Han <sebastien.han@enovance.com>
Wed, 17 Dec 2014 13:48:03 +0000 (14:48 +0100)
committerSébastien Han <sebastien.han@enovance.com>
Thu, 18 Dec 2014 10:49:32 +0000 (11:49 +0100)
We remove all the partitions, label and re-create something clean prior
to prepare the design. This will help solving many issues with existing
disks or while scratching/deploy test environments often.

Signed-off-by: Sébastien Han <sebastien.han@enovance.com>
roles/ceph-osd/tasks/journal_collocation.yml
roles/ceph-osd/tasks/raw_journal.yml [deleted file]
roles/ceph-osd/tasks/raw_multi_journal.yml
roles/ceph-osd/tasks/zap_devices.yml [new file with mode: 0644]
roles/ceph-osd/vars/main.yml

index 3012ee7fbb03c1788f60f370b2dc7161d54929f1..9ec42b79e5b31c3e3155d272eb9cb090c0c5f1ea 100644 (file)
@@ -1,6 +1,7 @@
 ---
 ## SCENARIO 1: JOURNAL AND OSD_DATA ON THE SAME DEVICE
 
+- include: zap_devices.yml
 - include: check_devices.yml
 
 # Prepare means
diff --git a/roles/ceph-osd/tasks/raw_journal.yml b/roles/ceph-osd/tasks/raw_journal.yml
deleted file mode 100644 (file)
index f9815ac..0000000
+++ /dev/null
@@ -1,95 +0,0 @@
----
-## SCENARIO 2: SINGLE JOURNAL DEVICE FOR N OSDS
-#
-
-- name: Install dependencies
-  apt: pkg=parted state=present
-  when: ansible_os_family == 'Debian'
-
-- name: Install dependencies
-  yum: name=parted state=present
-  when: ansible_os_family == 'RedHat'
-
-- name: Copy OSD bootstrap key
-  copy: src=fetch/{{ fsid }}/var/lib/ceph/bootstrap-osd/ceph.keyring dest=/var/lib/ceph/bootstrap-osd/ceph.keyring owner=root group=root mode=600
-  when: cephx
-
-# NOTE (leseb): current behavior of ceph-disk is to fail when the device is mounted "stderr: ceph-disk: Error: Device is mounted: /dev/sdb1"
-# the return code is 1, which makes sense, however ideally if ceph-disk will detect a ceph partition
-# it should exist we rc=0 and don't do anything unless we do something like --force
-# As as a final word, I prefer to keep the partition check instead of running ceph-disk prepare with "ignore_errors: True"
-# I believe it's safer
-#
-
-- name: Check if the 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
-  with_items: devices
-  register: parted
-  changed_when: False
-
-# Prepare means
-# - 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
-# - 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)
-#
-
-# NOTE (leseb): the prepare process must be parallelized somehow...
-# 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.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:
-# - mount the volume in a temp location
-# - allocate an osd id (if needed)
-# - remount in the correct location /var/lib/ceph/osd/$cluster-$id
-# - start ceph-osd
-#
-
-# This task is for disk devices 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
-
-- name: Start and add that the OSD service to the init sequence
-  service: name=ceph state=started enabled=yes args=osd
index 01147d63f5fbbea664e03b0ff5942194cdeff068..80e17c69b365489e11147ad3fb36b12cee150c2f 100644 (file)
@@ -1,6 +1,7 @@
 ---
 ## SCENARIO 3: N JOURNAL DEVICES FOR N OSDS
 
+- include: zap_devices.yml
 - include: check_devices.yml
 
 # Prepare means
diff --git a/roles/ceph-osd/tasks/zap_devices.yml b/roles/ceph-osd/tasks/zap_devices.yml
new file mode 100644 (file)
index 0000000..6372e0c
--- /dev/null
@@ -0,0 +1,13 @@
+---
+# NOTE (leseb): some devices might miss partition label which which will result
+# in ceph-disk failing to prepare OSD. Thus zapping them prior to prepare the OSD
+# ensures that the device will get successfully prepared.
+- name: Erasing partitions and labels from OSD disk(s)
+  command: ceph-disk zap {{ item }}
+  when: zap_devices and (journal_collocation or raw_multi_journal)
+  with_items: devices
+
+- name: Erasing partitions and labels from the journal device(s)
+  command: ceph-disk zap {{ item }}
+  when: zap_devices and raw_multi_journal
+  with_items: raw_journal_devices
index a47ff649ea814cd9571a72bf986d6be69370a5e0..06b93129a8bcbd3bc618da38ea1649ed594b71a2 100644 (file)
@@ -22,6 +22,9 @@ cephx: true
 #\r
 # !! WARNING !!\r
 \r
+# USE WITH CAUTION\r
+# Erase partitions structure and layout of the given devices below prior to prepare them\r
+zap_devices: false\r
 \r
 # Declare devices\r
 # All the scenarii inherit from the following device declaration\r