Skip to content

Commit

Permalink
Combine set_fact tasks
Browse files Browse the repository at this point in the history
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
  • Loading branch information
jimmymccrory committed Nov 11, 2016
1 parent d0fe1bd commit 08a97c5
Showing 1 changed file with 6 additions and 24 deletions.
30 changes: 6 additions & 24 deletions tasks/tempest_resources.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 08a97c5

Please sign in to comment.