Handle Ansible undefined loop variable
- Default docker_compose_deploy to empty list if undefined - Add conditional check to avoid looping through an empty list
This commit is contained in:
parent
7ee6e4810d
commit
a65c4b9cf6
@ -74,10 +74,10 @@
|
|||||||
delegate_to: "{{ inventory_hostname }}"
|
delegate_to: "{{ inventory_hostname }}"
|
||||||
register: compose_update
|
register: compose_update
|
||||||
notify: compose_restart
|
notify: compose_restart
|
||||||
loop: "{{ docker_compose_deploy }}"
|
loop: "{{ docker_compose_deploy | default([]) }}"
|
||||||
loop_control:
|
loop_control:
|
||||||
label: "{{ item.name }}"
|
label: "{{ item.name }}"
|
||||||
when: docker_compose_deploy is defined
|
when: docker_compose_deploy is defined and docker_compose_deploy | length > 0
|
||||||
|
|
||||||
- name: Set environment variables for docker-compose projects
|
- name: Set environment variables for docker-compose projects
|
||||||
ansible.builtin.template:
|
ansible.builtin.template:
|
||||||
|
Loading…
Reference in New Issue
Block a user