From 381af6c18de541be15ec23919d04b66641e55c11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Han?= Date: Mon, 19 Sep 2016 16:17:11 +0200 Subject: [PATCH] ceph-osd: get full link path when testing if a partition MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This allows us to test devices set with persistent naming such as /dev/disk/by-* When registering devices we can use persisent (/dev/disk/by-*) or non-persistent (/dev/sd*). Both declarations are supported by ceph-ansible. There was just two tasks that were not compatible with this. Since we support using partitions directly we need to test that because the device activation will be different. To test if the device is a partition we use a regular expression which wasn't compatible with the persistent device naming format (/dev/disk/by-*). This commit solves this issue by reading the path of the symlink since devices like /dev/disk/by-* are symlinks to devices like /dev/sd* Signed-off-by: Sébastien Han --- roles/ceph-osd/tasks/check_devices_auto.yml | 2 +- roles/ceph-osd/tasks/check_devices_static.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/roles/ceph-osd/tasks/check_devices_auto.yml b/roles/ceph-osd/tasks/check_devices_auto.yml index 7d17a57d5..ec80f85ea 100644 --- a/roles/ceph-osd/tasks/check_devices_auto.yml +++ b/roles/ceph-osd/tasks/check_devices_auto.yml @@ -1,6 +1,6 @@ --- - name: check if the device is a partition (autodiscover disks) - shell: "echo '/dev/{{ item.key }}' | egrep '/dev/([hsv]d[a-z]{1,2}|cciss/c[0-9]d[0-9]p|nvme[0-9]n[0-9]p)[0-9]{1,2}$'" + shell: "readlink -f /dev/{{ item.key }} | egrep '/dev/([hsv]d[a-z]{1,2}|cciss/c[0-9]d[0-9]p|nvme[0-9]n[0-9]p)[0-9]{1,2}$'" with_dict: "{{ ansible_devices }}" changed_when: false failed_when: false diff --git a/roles/ceph-osd/tasks/check_devices_static.yml b/roles/ceph-osd/tasks/check_devices_static.yml index 23d2f3b34..2a52762d6 100644 --- a/roles/ceph-osd/tasks/check_devices_static.yml +++ b/roles/ceph-osd/tasks/check_devices_static.yml @@ -1,6 +1,6 @@ --- - name: check if the device is a partition - shell: "echo '{{ item }}' | egrep '/dev/([hsv]d[a-z]{1,2}|cciss/c[0-9]d[0-9]p|nvme[0-9]n[0-9]p)[0-9]{1,2}$'" + shell: "readlink -f {{ item }} | egrep '/dev/([hsv]d[a-z]{1,2}|cciss/c[0-9]d[0-9]p|nvme[0-9]n[0-9]p)[0-9]{1,2}$'" with_items: "{{ devices }}" changed_when: false failed_when: false