Browse Source

Making mux with_items list evaluate as empty if didnt get objects before

ewolinetz 8 years ago
parent
commit
08c105c2b6

+ 1 - 1
roles/openshift_logging/tasks/start_cluster.yaml

@@ -36,7 +36,7 @@
     name: "{{ object }}"
     name: "{{ object }}"
     namespace: "{{openshift_logging_namespace}}"
     namespace: "{{openshift_logging_namespace}}"
     replicas: "{{ openshift_logging_mux_replica_count | default (1) }}"
     replicas: "{{ openshift_logging_mux_replica_count | default (1) }}"
-  with_items: "{{ mux_dc.results.results[0]['items'] | map(attribute='metadata.name') | list }}"
+  with_items: "{{ mux_dc.results.results[0]['items'] if 'results' in mux_dc else {} | map(attribute='metadata.name') | list }}"
   loop_control:
   loop_control:
     loop_var: object
     loop_var: object
   when:
   when:

+ 1 - 1
roles/openshift_logging/tasks/stop_cluster.yaml

@@ -36,7 +36,7 @@
     name: "{{ object }}"
     name: "{{ object }}"
     namespace: "{{openshift_logging_namespace}}"
     namespace: "{{openshift_logging_namespace}}"
     replicas: 0
     replicas: 0
-  with_items: "{{ mux_dc.results.results[0]['items'] | map(attribute='metadata.name') | list }}"
+  with_items: "{{ mux_dc.results.results[0]['items'] if 'results' in mux_dc else {} | map(attribute='metadata.name') | list }}"
   loop_control:
   loop_control:
     loop_var: object
     loop_var: object
   when: openshift_logging_use_mux
   when: openshift_logging_use_mux