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 ...