首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >找不到不可用的Firewalld模块

找不到不可用的Firewalld模块
EN

Stack Overflow用户
提问于 2022-02-22 13:56:12
回答 1查看 2K关注 0票数 1

环境信息:

代码语言:javascript
运行
复制
CentOS Stream release 8
Python 3.8.12
ansible [core 2.12.2]
  config file = /ansible/ansible-myprojects-rhel8/ansible.cfg
  configured module search path = ['/home/ansible/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.8/site-packages/ansible
  ansible collection location = /home/ansible/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/bin/ansible
  python version = 3.8.12 (default, Sep 21 2021, 00:10:52) [GCC 8.5.0 20210514 (Red Hat 8.5.0-3)]
  jinja version = 2.10.3
  libyaml = True

我试图在防火墙上为工作节点打开http端口。我的剧本如下:

代码语言:javascript
运行
复制
---
- name: enable web server
  hosts: target1
  tasks:
    - name: install stuff
      yum:
        name:
          - httpd
          - firewalld

    - name: create a welcome page
      copy:
        content: "welcome to the webserver \n"
        dest: /var/www/html/index.html

    - name: enable webserver
      service:
        name: httpd
        state: started
        enabled: true

    - name: enable firewall
      service:
        name: firewalld
        state: started
        enabled: true

    - name: open service in firewall
      firewalld:
        service: httpd
        permanent: true
        state: enabled
        immediate: yes

当我执行剧本时,它会产生错误:

错误!无法解析模块/动作“火瓦尔德”。这通常表示拼写错误、集合丢失或模块路径不正确。

代码语言:javascript
运行
复制
The error appears to be in '/ansible/ansible-myprojects-rhel8/exercise53_4.yaml': line 28, column 7, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:


    - name: open service in firewall
      ^ here

而不是我试图查看来自ansible控制器服务器的文档。比以下发生的错误:

代码语言:javascript
运行
复制
[WARNING]: module firewalld not found in: /home/ansible/.ansible/plugins/modules:/usr/share/ansible/plugins/modules:/usr/lib/python3.8/site-packages/ansible/modules

我不明白模块是不是不见了。它通过安装填充任务,该任务应该安装firewalld (如果安装了,则可以通过,但没有登录)。它只是跳过了防火墙中的任务开放服务并给出了错误)。

详细输出:

代码语言:javascript
运行
复制
ansible-playbook [core 2.12.2]
  config file = /ansible/ansible-myprojects-rhel8/ansible.cfg
  configured module search path = ['/home/ansible/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.8/site-packages/ansible
  ansible collection location = /home/ansible/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/bin/ansible-playbook
  python version = 3.8.12 (default, Sep 21 2021, 00:10:52) [GCC 8.5.0 20210514 (Red Hat 8.5.0-3)]
  jinja version = 2.10.3
  libyaml = True
Using /ansible/ansible-myprojects-rhel8/ansible.cfg as config file
redirecting (type: modules) ansible.builtin.firewalld to ansible.posix.firewalld
ERROR! couldn't resolve module/action 'firewalld'. This often indicates a misspelling, missing collection, or incorrect module path.

The error appears to be in '/ansible/ansible-myprojects-rhel8/exercise53_4.yaml': line 28, column 7, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:


    - name: open service in firewall
      ^ here 
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-02-23 08:42:13

我读了一篇关于包含firewalld模块的集合的文章,它没有安装在我的控制器节点上,而firewalld在ansible.posix集合中。

因此,我使用ansible user运行下面的命令:

代码语言:javascript
运行
复制
ansible-galaxy collection install ansible.posix

在此之后,问题就解决了,但是我不明白为什么当我第一次安装ansible (用yum)时,为什么没有将集合安装到我的控制器节点。如果有人对此有任何想法,请分享。

参考资料:http://www.freekb.net/Article?id=2991

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/71222581

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档