问题: ansible.posix 已安装,我的 python 和 ansible 版本都大大超过了 0.2.11 或 0.3.9...什么给出了?
错误:
TASK [site : permit traffic in default zone for https service] ***********************************************************************
failed: [website.com] (item=http) => {"ansible_loop_var": "item", "changed": false, "item": "http", "msg": "Failed to import the required Python library (firewall) on ubuntu's Python /usr/bin/python3. Please read the module documentation and install it in the appropriate location. If the required library is installed, but Ansible is using the wrong Python interpreter, please consult the documentation on ansible_python_interpreter. Version 0.2.11 or newer required (0.3.9 or newer for offline operations)"}
yaml:
- name: permit traffic in default zone for https service
ansible.posix.firewalld:
service: "{{ item }}"
permanent: true
state: enabled
immediate: yes
with_items:
- http
- https
ansible 和 python 版本:
➜ ansible git:(master) ✗ ansible --version
ansible [core 2.15.6]
config file = /Users/user/git/user/website.com/ansible/ansible.cfg
configured module search path = ['/Users/user/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /opt/homebrew/Cellar/ansible/8.6.1/libexec/lib/python3.12/site-packages/ansible
ansible collection location = /Users/user/.ansible/collections:/usr/share/ansible/collections
executable location = /opt/homebrew/bin/ansible
python version = 3.12.0 (main, Oct 5 2023, 15:44:07) [Clang 14.0.3 (clang-1403.0.22.14.1)] (/opt/homebrew/Cellar/ansible/8.6.1/libexec/bin/python)
jinja version = 3.1.2
libyaml = True
➜ ansible git:(master) ✗ python3 --version
Python 3.9.6
需求.yml
---
collections:
- name: ansible.posix
已验证 ansible.posix 已安装
➜ ansible git:(master) ✗ ansible-galaxy install -r requirements.yml --force
Starting galaxy collection install process
Process install dependency map
Starting collection install process
Downloading https://galaxy.ansible.com/api/v3/plugin/ansible/content/published/collections/artifacts/ansible-posix-1.5.4.tar.gz to /Users/user/.ansible/tmp/ansible-local-64903levgu9gv/tmpw5qhimud/ansible-posix-1.5.4-xonqklto
Installing 'ansible.posix:1.5.4' to '/Users/user/.ansible/collections/ansible_collections/ansible/posix'
ansible.posix:1.5.4 was installed successfully
ubuntu 22 使用 UFW,而不是防火墙。