.
├── test
│ └── ansible_poc_collection
│ ├── docs
│ ├── galaxy.yml
│ ├── plugins
│ │ └── README.md
│ ├── README.md
│ └── roles
│ └── testrole
│ └── tasks
│ └── main.yml
└── test-play.ymlgalaxy.yml包含命名空间和名称:
namespace: test
name: ansible_poc_collection在test-play.yml中,我从集合like this导入了测试角色
- hosts: all
collections:
- test.ansible_poc_collection
tasks:
- import_role:
name: testrole但它会抛出一个找不到角色的错误:
ERROR! the role 'testrole' was not found in /home/user/tests/ansible-poc-collection/roles:/home/user/.ansible/roles:/usr/share/ansible/roles:/etc/ansible/roles:/home/user/tests/ansible-poc-collection
The error appears to be in '/home/user/user/ansible-poc-collection/test-play.yml': line 6, column 15, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
- import_role:
name: testrole
^ here尝试创建一个顶级文件夹collections,并将集合移动到那里,使其位于collections/test/ansible_poc_collection中,同样的错误。此外,当使用集合命名空间/名称引用全名时:
- import_role:
name: test.ansible_poc_collection.testrole另一种无效的方法是设置COLLECTIONS_PATHS,使其指向我的集合的根目录(包含test命名空间文件夹):
COLLECTIONS_PATHS=/home/user/tests/ansible-poc-collection/collections ansible-playbook -i 127.0.0.1, test-play.yml如何在不构建存档和使用Ansible Galaxy的情况下在本地导入收藏?
使用的版本是2.9.6 (撰写本文时的最新稳定版本)
发布于 2020-03-20 08:21:31
好的,这基本上是一种变通方法。
只复制与剧本相邻的所需目录和相关目录(从集合目录)。
来源:https://docs.ansible.com/ansible/latest/user_guide/playbooks_best_practices.html#directory-layout
.
├── plugins
│ └── README.md
├── roles
│ └── testrole
│ └── tasks
│ └── main.yml
└── test-play.ymlhttps://stackoverflow.com/questions/60758949
复制相似问题