# Invalid interface clause error with ufw module and log param

**URL:** <https://forum.ansible.com/t/invalid-interface-clause-error-with-ufw-module-and-log-param/21919>\
**Category:** Ansible Project\
**Created:** [July 5, 2016, 12:19am UTC](https://forum.ansible.com/t/invalid-interface-clause-error-with-ufw-module-and-log-param/21919 "2016-07-05T00:19:45Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Guy\_Knights](https://avatars.discourse-cdn.com/v4/letter/g/db5fbb/32.png) [@Guy\_Knights](https://forum.ansible.com/u/Guy_Knights)\
**Post date:** [July 5, 2016, 12:19am UTC](https://forum.ansible.com/t/invalid-interface-clause-error-with-ufw-module-and-log-param/21919/1 "2016-07-05T00:19:45Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Guy\_Knights](https://avatars.discourse-cdn.com/v4/letter/g/db5fbb/32.png) [@Guy\_Knights](https://forum.ansible.com/u/Guy_Knights)\
**Post date:** [July 8, 2016, 5:30pm UTC](https://forum.ansible.com/t/invalid-interface-clause-error-with-ufw-module-and-log-param/21919/2 "2016-07-08T17:30:18Z")

</div>

I tried changing this task to not use a loop and instead just made it a standard task definition, as below:

- name: apply ssh rule  
ufw:  
port: 22  
proto: ‘tcp’  
src: ‘192.168.0.0/24’  
rule: allow  
direction: in  
log: ‘yes’  
interface: eth0  
state: enabled

I tried it with and without the interface parameter but I still get the same error, “Invalid interface clause”. The only interface in this machine is eth0 so the interface name is correct.

Does anyone have a solution for this?

Guy
