Allow devices to be partition instead of disks (used for some physical servers with a sigle disk for system and storage).

pull/89/head
Alexis Lahouze 2014-06-26 14:19:09 +02:00
parent a608b65cdd
commit 132e78df84
3 changed files with 108 additions and 21 deletions

View File

@ -21,6 +21,13 @@
# I believe it's safer # 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 - name: If partition named 'ceph' exists
shell: parted --script {{ item }} print | egrep -sq '^ 1.*ceph' shell: parted --script {{ item }} print | egrep -sq '^ 1.*ceph'
ignore_errors: True ignore_errors: True
@ -29,9 +36,9 @@
changed_when: False changed_when: False
# Prepare means # 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 # - 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 # - mark the fs as ready for ceph consumption
# - entire data disk is used (one big partition) # - entire data disk is used (one big partition)
# - a new partition is added to the journal disk (so it can be easily shared) # - a new partition is added to the journal disk (so it can be easily shared)
@ -41,12 +48,16 @@
# if you have 64 disks with 4TB each, this will take a while # if you have 64 disks with 4TB each, this will take a while
# since Ansible will sequential process the loop # 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) - name: Prepare OSD disk(s)
command: ceph-disk prepare {{ item.1 }} command: ceph-disk prepare {{ item.2 }}
when: item.0.rc != 0 and journal_collocation when: (item.0.rc != 0 or item.1.rc != 0) and journal_collocation
ignore_errors: True ignore_errors: True
with_together: with_together:
- parted.results - parted.results
- ispartition.results
- devices - devices
# Activate means: # Activate means:
@ -56,9 +67,27 @@
# - start ceph-osd # - start ceph-osd
# #
- name: Activate OSD(s) # This task if for disk device only because of the explicit use of the first
command: ceph-disk activate {{ item }}1 # partition.
with_items: devices
- 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 ignore_errors: True
changed_when: False changed_when: False

View File

@ -21,6 +21,13 @@
# I believe it's safer # 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 - name: If partition named 'ceph' exists
shell: parted --script {{ item }} print | egrep -sq '^ 1.*ceph' shell: parted --script {{ item }} print | egrep -sq '^ 1.*ceph'
ignore_errors: True ignore_errors: True
@ -29,9 +36,9 @@
changed_when: False changed_when: False
# Prepare means # 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 # - 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 # - mark the fs as ready for ceph consumption
# - entire data disk is used (one big partition) # - entire data disk is used (one big partition)
# - a new partition is added to the journal disk (so it can be easily shared) # - a new partition is added to the journal disk (so it can be easily shared)
@ -41,12 +48,16 @@
# if you have 64 disks with 4TB each, this will take a while # if you have 64 disks with 4TB each, this will take a while
# since Ansible will sequential process the loop # 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) - name: Prepare OSD disk(s)
command: ceph-disk prepare {{ item.1 }} {{ raw_journal_device }} command: ceph-disk prepare {{ item.2 }} {{ raw_journal_device }}
when: item.0.rc != 0 and raw_journal when: (item.0.rc != 0 or item.1.rc != 0) and raw_journal
ignore_errors: True ignore_errors: True
with_together: with_together:
- parted.results - parted.results
- ispartition.results
- devices - devices
# Activate means: # Activate means:
@ -56,9 +67,27 @@
# - start ceph-osd # - start ceph-osd
# #
- name: Activate OSD(s) # This task if for disk device only because of the explicit use of the first
command: ceph-disk activate {{ item }}1 # partition.
with_items: devices
- 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 ignore_errors: True
changed_when: False changed_when: False

View File

@ -21,6 +21,13 @@
# I believe it's safer # 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 - name: If partition named 'ceph' exists
shell: parted --script {{ item }} print | egrep -sq '^ 1.*ceph' shell: parted --script {{ item }} print | egrep -sq '^ 1.*ceph'
ignore_errors: True ignore_errors: True
@ -29,9 +36,9 @@
changed_when: False changed_when: False
# Prepare means # 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 # - 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 # - mark the fs as ready for ceph consumption
# - entire data disk is used (one big partition) # - entire data disk is used (one big partition)
# - a new partition is added to the journal disk (so it can be easily shared) # - a new partition is added to the journal disk (so it can be easily shared)
@ -41,12 +48,16 @@
# if you have 64 disks with 4TB each, this will take a while # if you have 64 disks with 4TB each, this will take a while
# since Ansible will sequential process the loop # 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) - name: Prepare OSD disk(s)
command: ceph-disk prepare {{ item.1 }} {{ item.2 }} command: ceph-disk prepare {{ item.2 }} {{ item.3 }}
when: item.0.rc != 0 and raw_multi_journal when: (item.0.rc != 0 or item.1.rc != 0) and raw_multi_journal
ignore_errors: True ignore_errors: True
with_together: with_together:
- parted.results - parted.results
- ispartition.results
- devices - devices
- raw_journal_devices - raw_journal_devices
@ -57,9 +68,27 @@
# - start ceph-osd # - start ceph-osd
# #
- name: Activate OSD(s) # This task if for disk device only because of the explicit use of the first
command: ceph-disk activate {{ item }}1 # partition.
with_items: devices
- 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 ignore_errors: True
changed_when: False changed_when: False