Skip to content

Commit

Permalink
ceph-facts: move device facts to its own file
Browse files Browse the repository at this point in the history
Instead of reusing the condition 'inventory_hostname in groups[osds]'
on each device facts tasks then we can move all the tasks into a
dedicated file and set the condition on the import_tasks statement.

Signed-off-by: Dimitri Savineau <dsavinea@redhat.com>
(cherry picked from commit d704b05)
  • Loading branch information
dsavineau authored and guits committed Jul 2, 2021
1 parent efd80b0 commit c97f90a
Show file tree
Hide file tree
Showing 2 changed files with 91 additions and 97 deletions.
88 changes: 88 additions & 0 deletions roles/ceph-facts/tasks/devices.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
---
- name: resolve device link(s)
command: readlink -f {{ item }}
changed_when: false
check_mode: no
with_items: "{{ devices }}"
register: devices_prepare_canonicalize
when:
- devices is defined
- not osd_auto_discovery | default(False) | bool

- name: set_fact build devices from resolved symlinks
set_fact:
devices: "{{ devices | default([]) + [ item.stdout ] }}"
with_items: "{{ devices_prepare_canonicalize.results }}"
when:
- devices is defined
- not osd_auto_discovery | default(False) | bool

- name: set_fact build final devices list
set_fact:
devices: "{{ devices | reject('search','/dev/disk') | list | unique }}"
when:
- devices is defined
- not osd_auto_discovery | default(False) | bool

- name: resolve dedicated_device link(s)
command: readlink -f {{ item }}
changed_when: false
check_mode: no
with_items: "{{ dedicated_devices }}"
register: dedicated_devices_prepare_canonicalize
when:
- dedicated_devices is defined
- not osd_auto_discovery | default(False) | bool

- name: set_fact build dedicated_devices from resolved symlinks
set_fact:
dedicated_devices: "{{ dedicated_devices | default([]) + [ item.stdout ] }}"
with_items: "{{ dedicated_devices_prepare_canonicalize.results }}"
when:
- dedicated_devices is defined
- not osd_auto_discovery | default(False) | bool

- name: set_fact build final dedicated_devices list
set_fact:
dedicated_devices: "{{ dedicated_devices | reject('search','/dev/disk') | list | unique }}"
when:
- dedicated_devices is defined
- not osd_auto_discovery | default(False) | bool

- name: resolve bluestore_wal_device link(s)
command: readlink -f {{ item }}
changed_when: false
check_mode: no
with_items: "{{ bluestore_wal_devices }}"
register: bluestore_wal_devices_prepare_canonicalize
when:
- bluestore_wal_devices is defined
- not osd_auto_discovery | default(False) | bool

- name: set_fact build bluestore_wal_devices from resolved symlinks
set_fact:
bluestore_wal_devices: "{{ bluestore_wal_devices | default([]) + [ item.stdout ] }}"
with_items: "{{ bluestore_wal_devices_prepare_canonicalize.results }}"
when:
- bluestore_wal_devices is defined
- not osd_auto_discovery | default(False) | bool

- name: set_fact build final bluestore_wal_devices list
set_fact:
bluestore_wal_devices: "{{ bluestore_wal_devices | reject('search','/dev/disk') | list | unique }}"
when:
- bluestore_wal_devices is defined
- not osd_auto_discovery | default(False) | bool

- name: set_fact devices generate device list when osd_auto_discovery
set_fact:
devices: "{{ (devices | default([]) + [ item.key | regex_replace('^', '/dev/') ]) | unique }}"
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
- item.key is not match osd_auto_discovery_exclude
100 changes: 3 additions & 97 deletions roles/ceph-facts/tasks/facts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -172,103 +172,9 @@
set_fact:
fsid: "{{ cluster_uuid.stdout }}"

- name: resolve device link(s)
command: readlink -f {{ item }}
changed_when: false
check_mode: no
with_items: "{{ devices }}"
register: devices_prepare_canonicalize
when:
- devices is defined
- inventory_hostname in groups.get(osd_group_name, [])
- not osd_auto_discovery | default(False) | bool

- name: set_fact build devices from resolved symlinks
set_fact:
devices: "{{ devices | default([]) + [ item.stdout ] }}"
with_items: "{{ devices_prepare_canonicalize.results }}"
when:
- devices is defined
- inventory_hostname in groups.get(osd_group_name, [])
- not osd_auto_discovery | default(False) | bool

- name: set_fact build final devices list
set_fact:
devices: "{{ devices | reject('search','/dev/disk') | list | unique }}"
when:
- devices is defined
- inventory_hostname in groups.get(osd_group_name, [])
- not osd_auto_discovery | default(False) | bool

- name: resolve dedicated_device link(s)
command: readlink -f {{ item }}
changed_when: false
check_mode: no
with_items: "{{ dedicated_devices }}"
register: dedicated_devices_prepare_canonicalize
when:
- dedicated_devices is defined
- inventory_hostname in groups.get(osd_group_name, [])
- not osd_auto_discovery | default(False) | bool

- name: set_fact build dedicated_devices from resolved symlinks
set_fact:
dedicated_devices: "{{ dedicated_devices | default([]) + [ item.stdout ] }}"
with_items: "{{ dedicated_devices_prepare_canonicalize.results }}"
when:
- dedicated_devices is defined
- inventory_hostname in groups.get(osd_group_name, [])
- not osd_auto_discovery | default(False) | bool

- name: set_fact build final dedicated_devices list
set_fact:
dedicated_devices: "{{ dedicated_devices | reject('search','/dev/disk') | list | unique }}"
when:
- dedicated_devices is defined
- inventory_hostname in groups.get(osd_group_name, [])
- not osd_auto_discovery | default(False) | bool

- name: resolve bluestore_wal_device link(s)
command: readlink -f {{ item }}
changed_when: false
check_mode: no
with_items: "{{ bluestore_wal_devices }}"
register: bluestore_wal_devices_prepare_canonicalize
when:
- bluestore_wal_devices is defined
- inventory_hostname in groups.get(osd_group_name, [])
- not osd_auto_discovery | default(False) | bool

- name: set_fact build bluestore_wal_devices from resolved symlinks
set_fact:
bluestore_wal_devices: "{{ bluestore_wal_devices | default([]) + [ item.stdout ] }}"
with_items: "{{ bluestore_wal_devices_prepare_canonicalize.results }}"
when:
- bluestore_wal_devices is defined
- inventory_hostname in groups.get(osd_group_name, [])
- not osd_auto_discovery | default(False) | bool

- name: set_fact build final bluestore_wal_devices list
set_fact:
bluestore_wal_devices: "{{ bluestore_wal_devices | reject('search','/dev/disk') | list | unique }}"
when:
- bluestore_wal_devices is defined
- inventory_hostname in groups.get(osd_group_name, [])
- not osd_auto_discovery | default(False) | bool

- name: set_fact devices generate device list when osd_auto_discovery
set_fact:
devices: "{{ (devices | default([]) + [ item.key | regex_replace('^', '/dev/') ]) | unique }}"
with_dict: "{{ ansible_facts['devices'] }}"
when:
- osd_auto_discovery | default(False) | bool
- inventory_hostname in groups.get(osd_group_name, [])
- ansible_facts['devices'] is defined
- item.value.removable == "0"
- item.value.sectors != "0"
- item.value.partitions|count == 0
- item.value.holders|count == 0
- item.key is not match osd_auto_discovery_exclude
- name: import_tasks devices.yml
import_tasks: devices.yml
when: inventory_hostname in groups.get(osd_group_name, [])

- name: backward compatibility tasks related
when:
Expand Down

0 comments on commit c97f90a

Please sign in to comment.