Combine set_fact tasks

Where two tasks are being used to set the same fact depending on a when
clause, use a ternary filter to combine them into a single task.

Change-Id: I128781dfad54a9543dac79c2406f1e6808816025
This commit is contained in:
Jimmy McCrory
2016-11-11 10:33:04 -08:00
parent d0fe1bd253
commit 08a97c5e6a

View File

@@ -35,17 +35,11 @@
delay: 15
when: tempest_service_available_glance | bool
- name: Store tempest image id
set_fact:
tempest_glance_image_id: "{{ tempest_image_create.id }}"
when: tempest_service_available_glance | bool
# This fact is used in tempest.conf.j2; we set an empty string if it doesn't get
# set above to ensure the template will parse correctly.
- name: Store empty tempest_glance_image_id fact
- name: Store tempest image id
set_fact:
tempest_glance_image_id: ''
when: not tempest_service_available_glance | bool
tempest_glance_image_id: "{{ tempest_service_available_glance | ternary(tempest_image_create.id, '') }}"
- name: Ensure alt tempest image
os_image:
@@ -60,17 +54,11 @@
register: tempest_image_alt_create
when: tempest_service_available_glance | bool
- name: Store alt tempest image id
set_fact:
tempest_glance_image_alt_id: "{{ tempest_image_alt_create.id }}"
when: tempest_service_available_glance | bool
# This fact is used in tempest.conf.j2; we set an empty string if it doesn't get
# set above to ensure the template will parse correctly.
- name: Store empty tempest_glance_image_alt_id fact
- name: Store alt tempest image id
set_fact:
tempest_glance_image_alt_id: ''
when: not tempest_service_available_glance | bool
tempest_glance_image_alt_id: "{{ tempest_service_available_glance | ternary(tempest_image_alt_create.id, '') }}"
- name: Ensure tempest tenants
keystone:
@@ -207,17 +195,11 @@
register: public_network
when: tempest_service_available_neutron | bool
- name: Store neutron public network id
set_fact:
tempest_neutron_public_network_id: "{{ public_network.id }}"
when: tempest_service_available_neutron | bool
# This fact is used in tempest.conf.j2; we set an empty string if it doesn't get
# set above to ensure the template will parse correctly.
- name: Store empty tempest_neutron_public_network_id fact
- name: Store neutron public network id
set_fact:
tempest_neutron_public_network_id: ''
when: not tempest_service_available_neutron | bool
tempest_neutron_public_network_id: "{{ tempest_service_available_neutron | ternary(public_network.id, '') }}"
- name: Ensure private subnet exists
os_subnet: