Skip to content

Commit db576c1

Browse files
committed
Use break_when when looping zones in ansible
This is a newer approach to break out of loops in ansible which is closer to what we originally intended.
1 parent dda17c6 commit db576c1

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

ansible/requirements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# TODO: unpin if RHEL 8 VMs on GCP update their python interpreter to 3.7+
22
# https://github.com/ansible/ansible/blob/v2.17.0/changelogs/CHANGELOG-v2.17.rst#removed-features-previously-deprecated
3-
ansible-core==2.16.10
4-
ansible==9.7.0
3+
ansible-core==2.18.7
4+
ansible==11.6.0
55
# TODO: unpin after https://github.com/docker/docker-py gets a release with
66
# https://github.com/docker/docker-py/commit/7785ad913ddf2d86478f08278bb2c488d05a29ff
77
requests==2.31.0

ansible/roles/create-vm/tasks/create-gcp-vm.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,8 @@
8080
loop: "{{ vm_available_zones }}"
8181
loop_control:
8282
loop_var: gcp_zone
83+
break_when:
84+
- (instance_result | default({'changed': false})).changed
8385
register: instance_result
8486
when: >
85-
(vm_arch == "amd64" or vm_arch == "arm64") and not condition and excluded == false
86-
vars:
87-
condition: "{{ (instance_result | default({'changed': false})).changed }}"
88-
87+
(vm_arch == "amd64" or vm_arch == "arm64") and not excluded

0 commit comments

Comments
 (0)