How to open firewall port with ansible firewalld task on Centos 7
<p>I have a task in my ansible-playbook script to open TCP port on a remote machine. but when I run my ansible playbook it throws an error. But when i run <code>"firewall-cmd --permanent --zone=public --add-port=1234/tcp"</code> and <code>"firewalld-cmd --reload"</code> I can see port is added in public zone.</p>

<p>Environment
Ansible local: OS x El Capitan
Ansible remote: AWS Centos 7 minimum version
Ansible version: 2.1.1.0
Remote python version: 2.7.5</p>

<p>My task </p>

<pre><code>- name: open management console port
  firewalld: port=1234/tcp zone=public permanent=true state=enabled immediate=yes
</code></pre>

<p>The error I am getting</p>

<pre><code>fatal: [X.X.X.X]: FAILED! =&gt; {"changed": false, "failed": true, "module_stderr": "", "module_stdout": "Traceback (most recent call last):\r\n  File \"/tmp/ansible_MojhHQ/ansible_module_firewalld.py\", line 605, in &lt;module&gt;\r\n    main()\r\n  File \"/tmp/ansible_MojhHQ/ansible_module_firewalld.py\", line 456, in main\r\n    is_enabled = get_port_enabled_permanent(zone, [port, protocol])\r\n  File \"/tmp/ansible_MojhHQ/ansible_module_firewalld.py\", line 170, in get_port_enabled_permanent\r\n    fw_zone = fw.config().getZoneByName(zone)\r\n  File \"&lt;string&gt;\", line 2, in getZoneByName\r\n  File \"/usr/lib/python2.7/site-packages/slip/dbus/polkit.py\", line 103, in _enable_proxy\r\n    return func(*p, **k)\r\n  File \"&lt;string&gt;\", line 2, in getZoneByName\r\n  File \"/usr/lib/python2.7/site-packages/firewall/client.py\", line 52, in handle_exceptions\r\n    return func(*args, **kwargs)\r\n  File \"/usr/lib/python2.7/site-packages/firewall/client.py\", line 1505, in getZoneByName\r\n    path = dbus_to_python(self.fw_config.getZoneByName(name))\r\n  File \"/usr/lib64/python2.7/site-packages/dbus/proxies.py\", line 70, in __call__\r\n    return self._proxy_method(*args, **keywords)\r\n  File \"/usr/lib/python2.7/site-packages/slip/dbus/proxies.py\", line 50, in __call__\r\n    return dbus.proxies._ProxyMethod.__call__(self, *args, **kwargs)\r\n  File \"/usr/lib64/python2.7/site-packages/dbus/proxies.py\", line 145, in __call__\r\n    **keywords)\r\n  File \"/usr/lib64/python2.7/site-packages/dbus/connection.py\", line 651, in call_blocking\r\n    message, timeout)\r\ndbus.exceptions.DBusException: org.fedoraproject.slip.dbus.service.PolKit.NotAuthorizedException.org.fedoraproject.FirewallD1.config: \r\n", "msg": "MODULE FAILURE", "parsed": false}
</code></pre>