Se firewall_allowed_ports
em:
- name: port {{ item }} allowed in firewall
ufw:
rule: allow
port: "{{ item }}"
proto: tcp
with_items:
- 22
- "{{ firewall_allowed_ports }}"
é indefinido, ocorre este erro:
fatal: [host.example.com]: FAILED! => {"failed": true, "msg": "the field 'args'
has an invalid value, which appears to include a variable that is undefined.
Tente resolver o problema
"{{ firewall_allowed_ports | }}"
resulta em:
fatal: [host.example.com]: FAILED! => {"failed": true, "msg": "template error
while templating string: expected token 'name', got 'end of print statement'.
String: {{ firewall_allowed_ports | }}"}
Use
default([])
para criar uma lista vazia sefirewall_allowed_ports
estiver indefinida. Owith_items
irá ignorá-lo quando estiver vazio.