- computer run ansible-playbook: MacBook, with python 3.9
- target machine: Debian 10 with python2.7.16 and python3.7.3
When I tried to open port in firewall:
- name: Open port 80 for http access
firewalld:
service: http
permanent: true
state: enabled
I got error:
fatal: [virtual_server]: FAILED! => {"changed": false, "msg": "Python
Module not found: firewalld and its python module are required for
this module, version 0.2.11 or newer required
(0.3.9 or newer for offline operations)"}
I also tried to use ansible.posix.firewall, with ansible-galaxy collection install ansible.posix
on macbook, and use ansible.posix.firewall, still got this error.
Can anybody tell me what is wrong?
4
Answers
ansible.posix.firewalld
depends on the python firewalld bindings which are missing for the python version ansible is running under.See https://bugzilla.redhat.com/show_bug.cgi?id=2091931 for a similar problem on systems using the EPEL8 ansible package, where the python3-firewall package is built against python 3.6 but ansible is using python 3.8.
ansible --version
orhead -1 $(which ansible)
will tell you what version of Python ansible uses.On redhat systems,
dnf repoquery -l python3-firewall
will tell you what version of Python python3-firewall is built against.The solution is to install the appropriate python-firewalld package for your OS that matches the version of python ansible is using, if one exists.
If a compatible python-firewalld package does not exist, you can configure ansible to use a different version of python by setting the
ansible_python_interpreter
variable or theinterpreter_python
ansible.cfg setting (see https://docs.ansible.com/ansible/latest/reference_appendices/interpreter_discovery.html).if you have your playbook vars like this
then your firewall task should be like this
The problem is that you propably have awx installed on docker and he dont have that galaxy package do this :
1. go to main server
find smt like this
2. connect to that docker image
3. Run command to install pkg
Done now run your playbook
I have fixed this problem by switch
ansible_connection
mode fromparamiko
tossh
on Ansible 5.10.0 x Ubuntu 22.04 .My changes.
Ansible version.
Pip versions of ansible.
Enjoy it.