The task includes an option with an undefined variable
14,331
Indentation of with_nested
is wrong. Correct syntax is
- name:
firewalld:
permanent: yes
port: "{{ item.0 }}"
state: enabled
zone: public
source: "{{ item.1 }}"
with_nested:
- "{{ ports }}"
- "{{ ips }}"
Author by
3amer_92
Updated on June 04, 2022Comments
-
3amer_92 almost 2 years
I have the below vars file and Ansible task which allows some ports for a specific source IPs on the firewall.
But for some reason, whenever I run the task I got this error:
FAILED! => {"msg": "The task includes an option with an undefined variable.
Even though I'm able to echo out these variables using
debug
Ansible module, so basically I'm just unable to use these variable specifically in this task.Ansible Task:
--- - name: firewalld: permanent: yes port: "{{ item.0 }}" state: enabled zone: public source: "{{ item.1 }}" with_nested: - "{{ ports }}" - "{{ ips }}"
Vars File:
ports: - "8000/tcp" - "9997/tcp" - "8181/tcp" - "8080/tcp" - "8191/tcp" - "8088/tcp" - "8065/tcp" ips: - "192.168.210.30/32" - "192.168.210.35/32" - "192.168.210.40/32" - "192.168.210.31/32" - "192.168.210.36/32" - "192.168.210.41/32" - "192.168.210.42/32" - "192.168.210.37/32"
-
Ravi Kulkarni over 4 yearsEven small space in yaml file makes difference.