win_firewall_rule "The property 'failed' cannot be found on this object. Verify that the property exists."

I’m running Ansible 2.0.0.2 on a Ubuntu 14.04 Control Machine, trying to enable an Inbound port on a target Windows Server 2012 R2 using the win_firewall_rule.

Here’s my playbook:

  • name: Allow inbound connection to port 12398

action: win_firewall_rule

args:

name: “Port 12398”

enabled: yes

state: present

localport: 12398

protocol: TCP

action: allow

direction: In

Receiving this error message:

FAILED! => {“changed”: false, “failed”: true, “invocation”: {“module_name”: “win_firewall_rule”}, “msg”: “The property ‘failed’ cannot be found on this object. Verify that the property exists.”}

Am I missing something or configured it wrong?

This is likely due to the change to enforce strict mode which was introduced in ansible 2.

There is an issue open on this module
https://github.com/ansible/ansible-modules-extras/issues/1406

If you can’t wait for the module to be fixed you could try setting strict mode off at the start of the module code

To do so, copy the module (win_firewall_rule.ps1 and win_firewall_rule.py) into your /etc/ansible/library or into your role’s library folder and then after

WANT_JSON

POWERSHELL_COMMON

add this line:
Set-StrictMode -Off

Might get you out of a hole.

Let us know how you get on.

Yep, that works!

Thanks Jon. Once again, you’ve helped me overcome a major hurdle.

-Joe