]> git.apps.os.sepia.ceph.com Git - ceph-ansible.git/commitdiff
ansible: fail if user selects OSD auto detection and raw devices are mounted 1633/head
authorDouglas Fuller <dfuller@redhat.com>
Thu, 29 Jun 2017 15:53:44 +0000 (15:53 +0000)
committerDouglas Fuller <dfuller@redhat.com>
Thu, 29 Jun 2017 17:02:17 +0000 (17:02 +0000)
Signed-off-by: Douglas Fuller <dfuller@redhat.com>
roles/ceph-osd/tasks/check_devices_auto.yml

index 4540e1b565706663220c39b216834fde380ab549..fa948106f6a80534010aa8d813d37302001a39b7 100644 (file)
     - ansible_devices is defined
     - item.value.removable == "0"
 
+- name: check if any of the raw partitions are mounted
+  shell: "mount |grep -sq '^/dev/{{ item.key }} '"
+  args:
+    warn: false
+  ignore_errors: yes
+  with_dict: "{{ ansible_devices }}"
+  register: mount_cmd
+  changed_when: false
+  always_run: true
+  when:
+    - ansible_devices is defined
+    - item.value.removable == "0"
+    - item.value.partitions|count == 0
+    - item.value.holders|count == 0
+
+- name: fail if any of the raw partitions are mounted
+  fail:
+    msg: "OSD device autodetection failed because one or more raw partitions is mounted on the host."
+  when: item.rc == 0
+  with_items: "{{ mount_cmd.results }}"
+
 - name: check the partition status of the osd disks (autodiscover disks)
   shell: "parted --script /dev/{{ item.key }} print > /dev/null 2>&1"
   with_dict: "{{ ansible_devices }}"