mirror of https://github.com/ceph/ceph-ansible.git
93 lines
2.9 KiB
YAML
93 lines
2.9 KiB
YAML
---
|
|
- name: find device used for operating system
|
|
command: findmnt -v -n -T / -o SOURCE
|
|
changed_when: false
|
|
register: root_device
|
|
|
|
- name: resolve root_device
|
|
command: "readlink -f {{ root_device.stdout }}"
|
|
changed_when: false
|
|
register: _root_device
|
|
|
|
- name: set_fact root_device
|
|
set_fact:
|
|
root_device: "{{ _root_device.stdout }}"
|
|
|
|
- name: lvm_volumes variable's tasks related
|
|
when:
|
|
- lvm_volumes is defined
|
|
- lvm_volumes | length > 0
|
|
block:
|
|
- name: resolve devices in lvm_volumes
|
|
command: "readlink -f {{ item.data }}"
|
|
changed_when: false
|
|
register: _lvm_volumes_data_devices
|
|
with_items: "{{ lvm_volumes }}"
|
|
when:
|
|
- item.data_vg is undefined
|
|
|
|
- name: set_fact lvm_volumes_data_devices
|
|
set_fact:
|
|
lvm_volumes_data_devices: "{{ lvm_volumes_data_devices | default([]) + [item.stdout] }}"
|
|
with_items: "{{ _lvm_volumes_data_devices.results }}"
|
|
when:
|
|
- item.skipped is undefined
|
|
|
|
- name: devices variable's tasks related
|
|
when:
|
|
- devices is defined
|
|
- devices | length > 0
|
|
block:
|
|
- name: resolve devices in devices
|
|
command: "readlink -f {{ item }}"
|
|
changed_when: false
|
|
register: devices_resolved
|
|
with_items: "{{ devices }}"
|
|
|
|
- name: set_fact devices_resolved
|
|
set_fact:
|
|
_devices: "{{ _devices | default([]) + [item.stdout] }}"
|
|
with_items: "{{ devices_resolved.results }}"
|
|
|
|
- name: fail if root_device is passed in lvm_volumes or devices
|
|
fail:
|
|
msg: "{{ root_device }} found in either lvm_volumes or devices variable"
|
|
when: root_device in lvm_volumes_data_devices | default([]) or root_device in _devices | default([])
|
|
|
|
- name: check no gpt header is present when osd scenario is lvm/lvm-batch
|
|
block:
|
|
- name: read information about the devices
|
|
parted:
|
|
device: "{{ item.data if item.data_vg is undefined and lvm_volumes is defined else item if devices is defined else omit }}"
|
|
unit: MiB
|
|
register: parted_results
|
|
with_items: "{{ lvm_volumes | default(devices) }}"
|
|
when:
|
|
- inventory_hostname in groups.get(osd_group_name, [])
|
|
- (item.data is defined and item.data_vg is undefined) or devices is defined
|
|
|
|
- name: fail when gpt header found on osd devices
|
|
fail:
|
|
msg: "{{ item.disk.dev }} has gpt header, please remove it."
|
|
with_items: "{{ parted_results.results }}"
|
|
when:
|
|
- item.skipped is undefined
|
|
- item.disk.table == 'gpt'
|
|
- item.partitions | length == 0
|
|
|
|
- name: check devices are block devices
|
|
block:
|
|
- name: get devices information
|
|
parted:
|
|
device: "{{ item }}"
|
|
unit: MiB
|
|
register: devices_parted
|
|
failed_when: False
|
|
with_items: "{{ devices | default([]) }}"
|
|
|
|
- name: fail if one of the devices is not a device
|
|
fail:
|
|
msg: "{{ item.item }} is not a block special file!"
|
|
when: item.rc is defined
|
|
with_items: "{{ devices_parted.results }}"
|