当我尝试在防火墙中打开端口时:
- name: Open port 80 for http access
firewalld:
service: http
permanent: true
state: enabled
Run Code Online (Sandbox Code Playgroud)
我收到错误:
致命:[虚拟服务器]:失败!=> {“changed”:false,“msg”:“找不到Python模块:此模块需要firewalld及其python模块,需要版本0.2.11或更高版本(离线操作为0.3.9或更高版本)”}
我也尝试ansible-galaxy collection install ansible.posix在macbook上使用ansible.posix.firewall,并使用ansible.posix.firewall,仍然出现此错误。
谁能告诉我出了什么问题吗?
ansible.posix.firewalld取决于运行 ansible 的 python 版本缺少的 python firewalld 绑定。
有关使用 EPEL8 ansible 软件包的系统上的类似问题,请参阅https://bugzilla.redhat.com/show_bug.cgi?id=2091931,其中 python3-firewall 软件包是针对 python 3.6 构建的,但 ansible 使用 python 3.8。
ansible --version或者head -1 $(which ansible)会告诉你 ansible 使用什么版本的 Python。
在 redhat 系统上,dnf repoquery -l python3-firewall将告诉您 python3-firewall 是针对哪个版本的 Python 构建的。
解决方案是为您的操作系统安装适当的 python-firewalld 软件包,该软件包与 ansible 正在使用的 python 版本相匹配(如果存在)。
如果不存在兼容的 python-firewalld 包,您可以通过设置变量ansible_python_interpreter或interpreter_pythonansible.cfg 设置来配置 ansible 使用不同版本的 python(请参阅https://docs.ansible.com/ansible/latest/reference_appendices/解释器_discovery.html)。
| 归档时间: |
|
| 查看次数: |
10694 次 |
| 最近记录: |