I have some tasks that use the ufw module to add firewall rules, which up until now have been working fine. Today however, I added the ‘log’ parameter to the ufw task and I got the following error: “ERROR: Invalid interface clause”.
My task definition is below:
- name: apply rules using ‘firewall’ variable defined in inventory vars
ufw:
port: “{{ item.0.port|default(omit) }}”
proto: “{{ item.0.proto|default(omit) }}”
src: “{{ item.1 }}”
rule: “{{ item.0.rule }}”
direction: “{{ item.0.direction|default(omit) }}”
log: “{{ item.0.log|default(‘no’) }}”
state: enabled
with_subelements: - “{{ firewall.rules }}”
- src
The troublesome firewall variable that’s failing for the task above is:
firewall:
rules:
ssh:
port: 22
proto: tcp
src: “{{ ips.ssh }}”
rule: allow
direction: in
log: ‘yes’
If I remove log: “{{ item.0.log|default(‘no’) }}” from the ufw task it works fine.
Thanks,
Guy