有没有什么好方法可以使用Ansible Galaxy命令安装并启用Ansible(2.7.9)自定义模块?
我的要求允许Ansible Galaxy下载正确的Ansible角色,该角色嵌入了我的自定义模块。一次ansible-galaxy install --roles-path ansible/roles/ -r roles/requirements.yml
,我得到以下结构(非详尽无遗):
├── ansible
│ ├── roles
│ │ ├── mymodule (being imported by Galaxy)
│ │ │ ├── library
│ │ │ │ └── mymodule.py
通过查看文档的这一部分,看来我的模块在正确的位置,不需要任何进一步的配置:https : //docs.ansible.com/ansible/latest/user_guide/playbooks_best_practices.html?highlight=library#目录布局
但是当我发现文档的这一部分时,我感到很困惑。是ANSIBLE_LIBRARY
有关自定义模块?
DEFAULT_MODULE_PATH
说明:用冒号分隔的路径,Ansible将在其中搜索模块。
类型:pathspec
默认值:〜/ .ansible / plugins / modules:/ usr / share / ansible / plugins / modules
INI部分:默认
这是关键:图书馆
环境:ANSIBLE_LIBRARY
https://docs.ansible.com/ansible/latest/reference_appendices/config.html#default-module-path
调用我的模块时
- name: Test of my Module
mymodule:
我收到以下错误:
ERROR! no action detected in task. This often indicates a misspelled module name, or incorrect module path.
我希望不必配置ANSIBLE_LIBRARY
和可自动调用的模块。我是否正确理解还是应该欺骗这个变量?
如果您的自定义模块属于某个角色,则需要将该角色包括在剧本中,因此至少:
---
- hosts: myhosts
roles:
- role: mymodule
tasks:
- name: Test of my Module
mymodule:
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句