]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-ansible.git/commitdiff
ceph-osd: fix register variable 536/head
authorSébastien Han <seb@redhat.com>
Thu, 11 Feb 2016 23:54:09 +0000 (00:54 +0100)
committerSébastien Han <seb@redhat.com>
Thu, 11 Feb 2016 23:54:09 +0000 (00:54 +0100)
as stated in https://github.com/ansible/ansible/issues/4297
if we register a variable twice and even if a task is skipped the
  register will not get overwritten... So we use the fact variant as
  mentionned in the ansible issue.

Signed-off-by: Sébastien Han <seb@redhat.com>
roles/ceph-osd/tasks/activate_osds.yml
roles/ceph-osd/tasks/check_devices.yml
roles/ceph-osd/tasks/scenarios/journal_collocation.yml
roles/ceph-osd/tasks/scenarios/raw_multi_journal.yml

index 0e5480c2f87a9e7a5deb8f0bf1403be8a7f7a360..e0c11f56b023bc6561691a60df9e2fb65613d2f6 100644 (file)
@@ -4,7 +4,7 @@
 - name: activate osd(s) when device is a disk
   command: ceph-disk activate {{ item.1 | regex_replace('^(\/dev\/cciss\/c[0-9]{1}d[0-9]{1})$', '\\1p') }}1
   with_together:
-    - ispartition.results
+    - combined_ispartition_results.results
     - devices
   changed_when: false
   failed_when: false
@@ -14,7 +14,7 @@
 - name: activate osd(s) when device is a partition
   command: "ceph-disk activate {{ item.1 }}"
   with_together:
-    - ispartition.results
+    - combined_ispartition_results.results
     - devices
   changed_when: false
   failed_when: false
index 7721046d219539bffa317117b0d16822cdd0d100..64d62c1a74222100803b74e4ea9261e612fadd41 100644 (file)
   with_dict: ansible_devices
   changed_when: false
   failed_when: false
-  register: ispartition
+  register: ispartition_autodiscover
   when:
     ansible_devices is defined and
     item.value.removable == "0" and
     osd_auto_discovery
 
+# NOTE (leseb): we must do this because of
+# https://github.com/ansible/ansible/issues/4297
+- name: combine ispartition results
+  set_fact:
+    combined_ispartition_results: "{{ ispartition if not osd_auto_discovery else ispartition_autodiscover }}"
+
 - name: check the partition status of the osd disks
   shell: "parted --script {{ item }} print > /dev/null 2>&1"
   with_items: devices
   register: osd_partition_status
   when:
     journal_collocation or
-    raw_multi_journal and
-    not osd_auto_discovery
+    raw_multi_journal and not
+    osd_auto_discovery
 
 - 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
   changed_when: false
   failed_when: false
-  register: osd_partition_status
+  register: osd_partition_status_autodiscover
   when:
     journal_collocation or
     raw_multi_journal and
     item.value.partitions|count == 0 and
     osd_auto_discovery
 
+# NOTE (leseb): we must do this because of
+# https://github.com/ansible/ansible/issues/4297
+- name: combine osd_partition_status results
+  set_fact:
+    combined_osd_partition_status_results: "{{ osd_partition_status if not osd_auto_discovery else osd_partition_status_autodiscover }}"
+
 - name: check the partition status of the journal devices
   shell: "parted --script {{ item }} print > /dev/null 2>&1"
   with_items: raw_journal_devices
@@ -65,7 +77,7 @@
 - name: fix partitions gpt header or labels of the osd disks
   shell: sgdisk --zap-all --clear --mbrtogpt -g -- {{ item.1 }}
   with_together:
-    - osd_partition_status.results
+    - combined_osd_partition_status_results.results
     - devices
   changed_when: false
   when:
@@ -76,7 +88,7 @@
 - name: fix partitions gpt header or labels of the osd disks (autodiscover disks)
   shell: sgdisk --zap-all --clear --mbrtogpt -g -- "/dev/{{ item.1.key }}"
   with_together:
-    - osd_partition_status.results
+    - combined_osd_partition_status_results.results
     - ansible_devices
   changed_when: false
   when:
   when: not osd_auto_discovery
 
 - name: check if a partition named 'ceph' exists (autodiscover disks)
-  shell: "parted --script {{ item }} print | egrep -sq '^ 1.*ceph'"
+  shell: "parted --script /dev/{{ item }} print | egrep -sq '^ 1.*ceph'"
   with_dict: ansible_devices
   changed_when: false
   failed_when: false
-  register: parted
+  register: parted_autodiscover
   when:
     ansible_devices is defined and
     item.value.removable == "0" and
+    item.value.partitions|count != 0 and
     osd_auto_discovery
+
+# NOTE (leseb): we must do this because of
+# https://github.com/ansible/ansible/issues/4297
+- name: combine parted results
+  set_fact:
+    combined_parted_results: "{{ parted if not osd_auto_discovery else parted_autodiscover }}"
index bd8a39c249cab72954f2e4190fb675985253432e..eff482bf9f971caabfe08d7902128d242ea5b393 100644 (file)
@@ -25,8 +25,8 @@
   command: "ceph-disk prepare {{ item.2 }}"
   ignore_errors: true
   with_together:
-    - parted.results
-    - ispartition.results
+    - combined_parted_results.results
+    - combined_ispartition_results.results
     - devices
   when:
     item.0.rc != 0 and
index 4a384f186d9e20c9884687eb7ace096c5227fa04..37f4aed20903866e1d1ddd841da34c710c2f189f 100644 (file)
@@ -12,8 +12,8 @@
 - name: prepare osd disk(s)
   command: "ceph-disk prepare {{ item.2 }} {{ item.3 }}"
   with_together:
-    - parted.results
-    - ispartition.results
+    - combined_parted_results.results
+    - combined_ispartition_results.results
     - devices
     - raw_journal_devices
   changed_when: false
@@ -21,6 +21,7 @@
   when:
     item.0.rc != 0 and
     item.1.rc != 0 and
-    raw_multi_journal
+    raw_multi_journal and
+    not osd_auto_discovery
 
 - include: ../activate_osds.yml