环境信息:
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端口。我的剧本如下:
---
- 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
当我执行剧本时,它会产生错误:
错误!无法解析模块/动作“火瓦尔德”。这通常表示拼写错误、集合丢失或模块路径不正确。
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控制器服务器的文档。比以下发生的错误:
[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 (如果安装了,则可以通过,但没有登录)。它只是跳过了防火墙中的任务开放服务并给出了错误)。
详细输出:
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
发布于 2022-02-23 08:42:13
我读了一篇关于包含firewalld模块的集合的文章,它没有安装在我的控制器节点上,而firewalld在ansible.posix集合中。
因此,我使用ansible user运行下面的命令:
ansible-galaxy collection install ansible.posix
在此之后,问题就解决了,但是我不明白为什么当我第一次安装ansible (用yum)时,为什么没有将集合安装到我的控制器节点。如果有人对此有任何想法,请分享。
https://stackoverflow.com/questions/71222581
复制相似问题