2020-12-17 03:18:08 +08:00
|
|
|
---
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Resolve devices
|
2020-12-17 03:18:08 +08:00
|
|
|
when:
|
|
|
|
- devices is defined
|
|
|
|
- not osd_auto_discovery | default(False) | bool
|
2023-02-14 01:07:25 +08:00
|
|
|
block:
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Resolve device link(s)
|
|
|
|
ansible.builtin.command: readlink -f {{ item }}
|
2023-02-14 01:07:25 +08:00
|
|
|
changed_when: false
|
2024-02-14 18:14:02 +08:00
|
|
|
check_mode: false
|
2023-02-14 01:07:25 +08:00
|
|
|
with_items: "{{ devices }}"
|
|
|
|
register: devices_prepare_canonicalize
|
2020-12-17 03:18:08 +08:00
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Set_fact build devices from resolved symlinks
|
|
|
|
ansible.builtin.set_fact:
|
|
|
|
devices: "{{ devices_prepare_canonicalize.results | map(attribute='stdout') | reject('search', '/dev/disk') | list | unique }}"
|
2020-12-17 03:18:08 +08:00
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Resolve dedicated_device
|
2020-12-17 03:18:08 +08:00
|
|
|
when:
|
|
|
|
- dedicated_devices is defined
|
|
|
|
- not osd_auto_discovery | default(False) | bool
|
2023-02-14 01:07:25 +08:00
|
|
|
block:
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Resolve dedicated_device link(s)
|
|
|
|
ansible.builtin.command: readlink -f {{ item }}
|
2023-02-14 01:07:25 +08:00
|
|
|
changed_when: false
|
2024-02-14 18:14:02 +08:00
|
|
|
check_mode: false
|
2023-02-14 01:07:25 +08:00
|
|
|
with_items: "{{ dedicated_devices }}"
|
|
|
|
register: dedicated_devices_prepare_canonicalize
|
2020-12-17 03:18:08 +08:00
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Set_fact build dedicated_devices from resolved symlinks
|
|
|
|
ansible.builtin.set_fact:
|
|
|
|
dedicated_devices: "{{ dedicated_devices_prepare_canonicalize.results | map(attribute='stdout') | reject('search', '/dev/disk') | list | unique }}"
|
2020-12-17 03:18:08 +08:00
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Resolve bluestore_wal_device
|
2020-12-17 03:18:08 +08:00
|
|
|
when:
|
|
|
|
- bluestore_wal_devices is defined
|
|
|
|
- not osd_auto_discovery | default(False) | bool
|
2023-02-14 01:07:25 +08:00
|
|
|
block:
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Resolve bluestore_wal_device link(s)
|
|
|
|
ansible.builtin.command: readlink -f {{ item }}
|
2023-02-14 01:07:25 +08:00
|
|
|
changed_when: false
|
2024-02-14 18:14:02 +08:00
|
|
|
check_mode: false
|
2023-02-14 01:07:25 +08:00
|
|
|
with_items: "{{ bluestore_wal_devices }}"
|
|
|
|
register: bluestore_wal_devices_prepare_canonicalize
|
2020-12-17 03:18:08 +08:00
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Set_fact build bluestore_wal_devices from resolved symlinks
|
|
|
|
ansible.builtin.set_fact:
|
|
|
|
bluestore_wal_devices: "{{ bluestore_wal_devices_prepare_canonicalize.results | map(attribute='stdout') | reject('search', '/dev/disk') | list | unique }}"
|
2020-12-17 03:18:08 +08:00
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Set_fact devices generate device list when osd_auto_discovery
|
2022-01-16 00:34:03 +08:00
|
|
|
vars:
|
|
|
|
device: "{{ item.key | regex_replace('^', '/dev/') }}"
|
2024-02-14 18:14:02 +08:00
|
|
|
ansible.builtin.set_fact:
|
2022-01-16 00:34:03 +08:00
|
|
|
devices: "{{ devices | default([]) | union([device]) }}"
|
2020-12-17 03:18:08 +08:00
|
|
|
with_dict: "{{ ansible_facts['devices'] }}"
|
|
|
|
when:
|
|
|
|
- osd_auto_discovery | default(False) | bool
|
|
|
|
- ansible_facts['devices'] is defined
|
|
|
|
- item.value.removable == "0"
|
|
|
|
- item.value.sectors != "0"
|
|
|
|
- item.value.partitions|count == 0
|
|
|
|
- item.value.holders|count == 0
|
2022-04-04 17:48:14 +08:00
|
|
|
- ansible_facts['mounts'] | selectattr('device', 'equalto', device) | list | length == 0
|
2020-12-17 03:18:08 +08:00
|
|
|
- item.key is not match osd_auto_discovery_exclude
|
2023-02-14 00:12:41 +08:00
|
|
|
- device not in dedicated_devices | default([])
|
|
|
|
- device not in bluestore_wal_devices | default([])
|
2023-02-26 22:08:09 +08:00
|
|
|
- device not in (lvm_volumes | default([]) | map(attribute='data') | list)
|