2018-07-18 21:59:22 +08:00
|
|
|
---
|
2019-10-08 20:42:44 +08:00
|
|
|
- name: set_fact root_device
|
|
|
|
set_fact:
|
2020-12-16 04:04:57 +08:00
|
|
|
root_device: "{{ ansible_facts['mounts'] | selectattr('mount', 'match', '^/$') | map(attribute='device') | first }}"
|
2019-10-08 20:42:44 +08:00
|
|
|
|
|
|
|
- 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 }}"
|
2020-12-16 06:34:34 +08:00
|
|
|
when: item.data_vg is undefined
|
2019-10-08 20:42:44 +08:00
|
|
|
|
|
|
|
- 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 }}"
|
2020-12-16 06:34:34 +08:00
|
|
|
when: item.skipped is undefined
|
2019-10-08 20:42:44 +08:00
|
|
|
|
|
|
|
- name: fail if root_device is passed in lvm_volumes or devices
|
|
|
|
fail:
|
|
|
|
msg: "{{ root_device }} found in either lvm_volumes or devices variable"
|
2020-12-16 04:02:59 +08:00
|
|
|
when: root_device in lvm_volumes_data_devices | default([]) or root_device in devices | default([])
|
2019-10-08 20:42:44 +08:00
|
|
|
|
2019-10-01 15:34:14 +08:00
|
|
|
- name: check devices are block devices
|
|
|
|
block:
|
2019-06-07 16:50:28 +08:00
|
|
|
- name: get devices information
|
2018-11-10 01:20:05 +08:00
|
|
|
parted:
|
|
|
|
device: "{{ item }}"
|
|
|
|
unit: MiB
|
|
|
|
register: devices_parted
|
2019-06-07 16:50:28 +08:00
|
|
|
failed_when: False
|
2020-12-16 04:00:28 +08:00
|
|
|
with_items:
|
|
|
|
- "{{ devices | default([]) }}"
|
2020-12-16 04:08:00 +08:00
|
|
|
- "{{ dedicated_devices | default([]) }}"
|
|
|
|
- "{{ bluestore_wal_devices | default([]) }}"
|
2020-12-16 04:00:28 +08:00
|
|
|
- "{{ lvm_volumes_data_devices | default([]) }}"
|
2018-07-18 21:59:22 +08:00
|
|
|
|
2018-11-10 01:20:05 +08:00
|
|
|
- name: fail if one of the devices is not a device
|
|
|
|
fail:
|
validate: improve message printed in check_devices.yml
The message prints the whole content of the registered variable in the
playbook, this is not needed and makes the message pretty unclear and
unreadable.
```
"msg": "{'_ansible_parsed': True, 'changed': False, '_ansible_no_log': False, u'err': u'Error: Could not stat device /dev/sdf - No such file or directory.\\n', 'item': u'/dev/sdf', '_ansible_item_result': True, u'failed': False, '_ansible_item_label': u'/dev/sdf', u'msg': u\"Error while getting device information with parted script: '/sbin/parted -s -m /dev/sdf -- unit 'MiB' print'\", u'rc': 1, u'invocation': {u'module_args': {u'part_start': u'0%', u'part_end': u'100%', u'name': None, u'align': u'optimal', u'number': None, u'label': u'msdos', u'state': u'info', u'part_type': u'primary', u'flags': None, u'device': u'/dev/sdf', u'unit': u'MiB'}}, 'failed_when_result': False, '_ansible_ignore_errors': None, u'out': u''} is not a block special file!"
```
Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1719023
Signed-off-by: Guillaume Abrioux <gabrioux@redhat.com>
2019-07-10 21:08:39 +08:00
|
|
|
msg: "{{ item.item }} is not a block special file!"
|
2019-06-07 16:50:28 +08:00
|
|
|
when: item.rc is defined
|
2018-11-10 01:20:05 +08:00
|
|
|
with_items: "{{ devices_parted.results }}"
|
2020-12-16 04:00:28 +08:00
|
|
|
|
|
|
|
- name: fail when gpt header found on osd devices
|
|
|
|
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
|
2020-12-16 06:34:34 +08:00
|
|
|
|
|
|
|
- name: check logical volume in lvm_volumes
|
|
|
|
when: lvm_volumes is defined
|
|
|
|
block:
|
|
|
|
- name: check data logical volume
|
|
|
|
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
|
|
|
|
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
|
|
|
|
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
|
|
|
|
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
|
|
|
|
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
|
|
|
|
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
|
|
|
|
|
|
|
|
- name: check filestore journal logical volume
|
|
|
|
stat:
|
|
|
|
path: "/dev/{{ item.journal_vg }}/{{ item.journal }}"
|
|
|
|
follow: true
|
|
|
|
register: lvm_volumes_journal
|
|
|
|
loop: "{{ lvm_volumes }}"
|
|
|
|
when:
|
|
|
|
- osd_objectstore == 'filestore'
|
|
|
|
- item.journal is defined
|
|
|
|
- item.journal_vg is defined
|
|
|
|
|
|
|
|
- name: fail if one of the filestore journal logical volume is not a device or doesn't exist
|
|
|
|
fail:
|
|
|
|
msg: "{{ item.item.journal_vg }}/{{ item.item.journal }} doesn't exist or isn't a block"
|
|
|
|
loop: "{{ lvm_volumes_journal.results }}"
|
|
|
|
when:
|
|
|
|
- item.skipped is undefined
|
|
|
|
- not item.stat.exists | bool or not item.stat.isblk | bool
|