mirror of https://github.com/ceph/ceph-ansible.git
116 lines
4.1 KiB
YAML
116 lines
4.1 KiB
YAML
---
|
|
- name: Set_fact root_device
|
|
ansible.builtin.set_fact:
|
|
root_device: "{{ ansible_facts['mounts'] | selectattr('mount', 'match', '^/$') | map(attribute='device') | first }}"
|
|
|
|
- name: Lvm_volumes variable's tasks related
|
|
when:
|
|
- lvm_volumes is defined
|
|
- lvm_volumes | length > 0
|
|
block:
|
|
- name: Resolve devices in lvm_volumes
|
|
ansible.builtin.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
|
|
ansible.builtin.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: Fail if root_device is passed in lvm_volumes or devices
|
|
ansible.builtin.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 devices are block devices
|
|
block:
|
|
- name: Get devices information
|
|
community.general.parted:
|
|
device: "{{ item }}"
|
|
unit: MiB
|
|
register: devices_parted
|
|
failed_when: false
|
|
with_items:
|
|
- "{{ devices | default([]) }}"
|
|
- "{{ dedicated_devices | default([]) }}"
|
|
- "{{ bluestore_wal_devices | default([]) }}"
|
|
- "{{ lvm_volumes_data_devices | default([]) }}"
|
|
|
|
- name: Fail if one of the devices is not a device
|
|
ansible.builtin.fail:
|
|
msg: "{{ item.item }} is not a block special file!"
|
|
when: item.rc is defined
|
|
with_items: "{{ devices_parted.results }}"
|
|
|
|
- name: Fail when gpt header found on osd devices
|
|
ansible.builtin.fail:
|
|
msg: "{{ item.disk.dev }} has gpt header, please remove it."
|
|
with_items: "{{ devices_parted.results }}"
|
|
when:
|
|
- item.skipped is undefined
|
|
- item.disk.table == 'gpt'
|
|
- item.partitions | length == 0
|
|
|
|
- name: Check logical volume in lvm_volumes
|
|
when: lvm_volumes is defined
|
|
block:
|
|
- name: Check data logical volume
|
|
ansible.builtin.stat:
|
|
path: "/dev/{{ item.data_vg }}/{{ item.data }}"
|
|
follow: true
|
|
register: lvm_volumes_data
|
|
loop: "{{ lvm_volumes }}"
|
|
when:
|
|
- item.data is defined
|
|
- item.data_vg is defined
|
|
|
|
- name: Fail if one of the data logical volume is not a device or doesn't exist
|
|
ansible.builtin.fail:
|
|
msg: "{{ item.item.data_vg }}/{{ item.item.data }} doesn't exist or isn't a block"
|
|
loop: "{{ lvm_volumes_data.results }}"
|
|
when:
|
|
- item.skipped is undefined
|
|
- not item.stat.exists | bool or not item.stat.isblk | bool
|
|
|
|
- name: Check bluestore db logical volume
|
|
ansible.builtin.stat:
|
|
path: "/dev/{{ item.db_vg }}/{{ item.db }}"
|
|
follow: true
|
|
register: lvm_volumes_db
|
|
loop: "{{ lvm_volumes }}"
|
|
when:
|
|
- osd_objectstore == 'bluestore'
|
|
- item.db is defined
|
|
- item.db_vg is defined
|
|
|
|
- name: Fail if one of the bluestore db logical volume is not a device or doesn't exist
|
|
ansible.builtin.fail:
|
|
msg: "{{ item.item.db_vg }}/{{ item.item.db }} doesn't exist or isn't a block"
|
|
loop: "{{ lvm_volumes_db.results }}"
|
|
when:
|
|
- item.skipped is undefined
|
|
- not item.stat.exists | bool or not item.stat.isblk | bool
|
|
|
|
- name: Check bluestore wal logical volume
|
|
ansible.builtin.stat:
|
|
path: "/dev/{{ item.wal_vg }}/{{ item.wal }}"
|
|
follow: true
|
|
register: lvm_volumes_wal
|
|
loop: "{{ lvm_volumes }}"
|
|
when:
|
|
- osd_objectstore == 'bluestore'
|
|
- item.wal is defined
|
|
- item.wal_vg is defined
|
|
|
|
- name: Fail if one of the bluestore wal logical volume is not a device or doesn't exist
|
|
ansible.builtin.fail:
|
|
msg: "{{ item.item.wal_vg }}/{{ item.item.wal }} doesn't exist or isn't a block"
|
|
loop: "{{ lvm_volumes_wal.results }}"
|
|
when:
|
|
- item.skipped is undefined
|
|
- not item.stat.exists | bool or not item.stat.isblk | bool
|