Rocky 9 的ansible中没有mount模块
报错The module mount was redirected to ansible.posix.mount, which could not be loaded.
[root@master-61 ~]#ansible test -m mount -a 'src=172.16.1.31:/data path=/usr/share/nginx/html fstype=nfs opts=defaults state=mounted'
172.16.1.110 | FAILED! => {
"msg": "The module mount was redirected to ansible.posix.mount, which could not be loaded."
}
查看模块提示未找到
[root@master-61 ~]#ansible-doc mount
[WARNING]: mount was not found
查看ansible版本
[root@master-61 ~]#ansible --version
ansible [core 2.14.17]
config file = /etc/ansible/ansible.cfg
configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python3.9/site-packages/ansible
ansible collection location = /root/.ansible/collections:/usr/share/ansible/collections
executable location = /usr/bin/ansible
python version = 3.9.19 (main, Sep 11 2024, 00:00:00) [GCC 11.5.0 20240719 (Red Hat 11.5.0-2)] (/usr/bin/python3)
jinja version = 3.1.2
libyaml = True
在官网找到了原因,ansible-core
中未包含ansible.posix
,需要手动安装这个集合
You might already have this collection installed if you are using the ansible package. It is not included in ansible-core. To check whether it is installed, run
ansible-galaxy collection list
.
To install it, use:
ansible-galaxy collection install ansible.posix
.
To use it in a playbook, specify:ansible.posix.mount
.
原文:https://docs.ansible.com/ansible/latest/collections/ansible/posix/mount_module.html
安装成功
[root@master-61 ~]#ansible-galaxy collection install ansible.posix
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-2.0.0.tar.gz to /root/.ansible/tmp/ansible-local-6643al966noi/tmpzj9e8md9/ansible-posix-2.0.0-4j26zgak
Installing 'ansible.posix:2.0.0' to '/root/.ansible/collections/ansible_collections/ansible/posix'
ansible.posix:2.0.0 was installed successfully
查看模块文档:
[root@master-61 ~]#ansible-doc -l | grep mount
[WARNING]: Collection ansible.posix does not support Ansible version 2.14.17
ansible.posix.mount Control active and configured mount ...
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· .NET10 - 预览版1新功能体验(一)