Ansible 社区包中的 firewalld 模块和 Python3 绑定

发布于 2025-01-20 20:34:03 字数 2572 浏览 0 评论 0原文

我正在使用Python3运行Ansible Community Package 5.6,

# ansible-playbook --version
ansible-playbook [core 2.12.4]
  config file = /opt/work/ansible/ansible.cfg
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python3.8/site-packages/ansible
  ansible collection location = /usr/local/lib/python3.8/site-packages/ansible_collections
  executable location = /usr/local/bin/ansible-playbook
  python version = 3.8.13 ...
  jinja version = 3.1.1
  libyaml = True

以下剧本,

---
- hosts: localhost
  tasks:
  - name: Open ports
    firewalld:
      zone: "public"
      port: "58080/tcp"
      permanent: true
      immediate: true
      state: enabled
    become: true
    become_method: sudo

失败的错误

fatal: [localhost]: FAILED! => {
    "changed": false,
    "invocation": {
        "module_args": {
            "icmp_block": null,
            "icmp_block_inversion": null,
            "immediate": true,
            "interface": null,
            "masquerade": null,
            "offline": null,
            "permanent": true,
            "port": "58080/tcp",
            "port_forward": null,
            "rich_rule": null,
            "service": null,
            "source": null,
            "state": "enabled",
            "target": null,
            "timeout": 0,
            "zone": "public"
        }
    },
    "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)"
}

firewalld 默认情况下已经安装了模块或Ansible.posix Collection,

# ansible-galaxy collection list

# /usr/local/lib/python3.8/site-packages/ansible_collections
Collection                    Version
----------------------------- -------
amazon.aws                    2.2.0
ansible.netcommon             2.6.1
ansible.posix                 1.3.0

我注意到Ansible Python模块和收集位置(如上图所示)并不指向/usr/usr//usr/ local/lib/python3.8/site-ackages/ansible_collections,我们需要配置这两个位置吗?

此外,一个需要将ANSIBLE_PYTHON_INTERPRETER设置为Python3解释器路径并安装Python3绑定。到底在哪里下载并安装Python3绑定?

I'm running Ansible Community Package 5.6 with Python3,

# ansible-playbook --version
ansible-playbook [core 2.12.4]
  config file = /opt/work/ansible/ansible.cfg
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python3.8/site-packages/ansible
  ansible collection location = /usr/local/lib/python3.8/site-packages/ansible_collections
  executable location = /usr/local/bin/ansible-playbook
  python version = 3.8.13 ...
  jinja version = 3.1.1
  libyaml = True

The following playbook,

---
- hosts: localhost
  tasks:
  - name: Open ports
    firewalld:
      zone: "public"
      port: "58080/tcp"
      permanent: true
      immediate: true
      state: enabled
    become: true
    become_method: sudo

failed with the error

fatal: [localhost]: FAILED! => {
    "changed": false,
    "invocation": {
        "module_args": {
            "icmp_block": null,
            "icmp_block_inversion": null,
            "immediate": true,
            "interface": null,
            "masquerade": null,
            "offline": null,
            "permanent": true,
            "port": "58080/tcp",
            "port_forward": null,
            "rich_rule": null,
            "service": null,
            "source": null,
            "state": "enabled",
            "target": null,
            "timeout": 0,
            "zone": "public"
        }
    },
    "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)"
}

The firewalld module or the ansible.posix collection is already installed by default,

# ansible-galaxy collection list

# /usr/local/lib/python3.8/site-packages/ansible_collections
Collection                    Version
----------------------------- -------
amazon.aws                    2.2.0
ansible.netcommon             2.6.1
ansible.posix                 1.3.0

I noticed that the ansible python module and collection location (shown in the above --version) are not pointing to /usr/local/lib/python3.8/site-packages/ansible_collections, do we need to configure these two locations?

In addition, one of the notes explained that we need set ansible_python_interpreter to python3 interpreter path and install the python3 bindings. Exactly where to download and install the python3 bindings?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

小帐篷 2025-01-27 20:34:03

问题在于您预计将AWX安装在Docker上,他没有Galaxy包来做到这一点:

1。转到主服务器

 > docker images

找到这样的SMT

ansible/awx    17.1.0    {here_id_of_image}   16 months ago    1.41GB

2。连接到该码头图像

> docker run -it {here_id_of_image} bash

3。运行命令安装PKG

> ansible-galaxy collection install ansible.posix

现在运行您的剧本

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

 > docker images

find smt like this

ansible/awx    17.1.0    {here_id_of_image}   16 months ago    1.41GB

2. connect to that docker image

> docker run -it {here_id_of_image} bash

3. Run command to install pkg

> ansible-galaxy collection install ansible.posix

Done now run your playbook

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文