]> git.apps.os.sepia.ceph.com Git - ceph-ansible.git/commitdiff
devices: test devices before collecting on auto discovery
authorSeena Fallah <seenafallah@gmail.com>
Tue, 30 Jul 2024 20:11:55 +0000 (22:11 +0200)
committerTeoman ONAY <tonay@ibm.com>
Tue, 13 Aug 2024 16:10:44 +0000 (18:10 +0200)
In some scenarios with NVMe, a device might be identified by
Ansible but could actually be a multipath device rather than an
actual device. We need to exclude these as Ceph cannot create
OSDs on them.

Signed-off-by: Seena Fallah <seenafallah@gmail.com>
(cherry picked from commit be9b45852459434184b576d85ad80f505ee7ea3f)

roles/ceph-facts/tasks/devices.yml

index ea20c252d527406ea42799d35d15a9ca1677b888..95bd82a830c6eb9d4ac40be9dfcdba370590a69a 100644 (file)
       ansible.builtin.set_fact:
         bluestore_wal_devices: "{{ bluestore_wal_devices_prepare_canonicalize.results | map(attribute='stdout') | reject('search', '/dev/disk') | list | unique }}"
 
-- name: Set_fact devices generate device list when osd_auto_discovery
+- name: Collect existed devices
   vars:
     device: "{{ item.key | regex_replace('^', '/dev/') }}"
-  ansible.builtin.set_fact:
-    devices: "{{ devices | default([]) | union([device]) }}"
-  with_dict: "{{ ansible_facts['devices'] }}"
+  ansible.builtin.command: test -b {{ device }}
+  changed_when: false
+  ignore_errors: true
+  loop: "{{ ansible_facts['devices'] | dict2items }}"
   when:
     - osd_auto_discovery | default(False) | bool
     - ansible_facts['devices'] is defined
     - device not in dedicated_devices | default([])
     - device not in bluestore_wal_devices | default([])
     - device not in (lvm_volumes | default([]) | map(attribute='data') | list)
+  register: devices_check
+
+- name: Set_fact devices generate device list when osd_auto_discovery
+  vars:
+    device: "{{ item.item.key | regex_replace('^', '/dev/') }}"
+  ansible.builtin.set_fact:
+    devices: "{{ devices | default([]) | union([device]) }}"
+  loop: "{{ devices_check.results }}"
+  when:
+    - devices_check is defined
+    - not item.skipped | default(false)
+    - not item.failed | default(false)