从当前文件夹本地导入playbook中的Ansible集合,无需打包或使用galaxy
从当前文件夹本地导入playbook中的Ansible集合,无需打包或使用galaxy,ansible,yaml,roles,Ansible,Yaml,Roles,galaxy.yml包含名称空间和名称: . ├── test │ └── ansible_poc_collection │ ├── docs │ ├── galaxy.yml │ ├── plugins │ │ └── README.md │ ├── README.md │ └── roles │ └── testrole │ └── tasks │
galaxy.yml
包含名称空间和名称:
.
├── test
│ └── ansible_poc_collection
│ ├── docs
│ ├── galaxy.yml
│ ├── plugins
│ │ └── README.md
│ ├── README.md
│ └── roles
│ └── testrole
│ └── tasks
│ └── main.yml
└── test-play.yml
在test play.yml
中,我从集合中导入testrole:
但它会抛出一个错误,即找不到角色:
- hosts: all
collections:
- test.ansible_poc_collection
tasks:
- import_role:
name: testrole
尝试创建顶级文件夹collections
,并将集合移动到那里,使其位于collections/test/ansible\u poc\u collection
,出现相同错误。同样,在使用集合命名空间/名称引用全名时:
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\u路径
,使其指向我的集合的根目录(包含test
命名空间文件夹):
如何在本地导入收藏而不构建存档并使用Ansible Galaxy
使用的版本是2.9.6(撰写本文时最新的稳定版本)好的,这基本上是一个解决方法 仅复制playbook附近所需的目录和从属目录(从集合目录) 资料来源:
好的,这基本上是一个解决办法 仅复制playbook附近所需的目录和从属目录(从集合目录) 资料来源:
好的,这基本上是一个解决办法。仅复制playbook附近所需的目录和从属目录(从集合目录)\n来源:\n。├── 插件│ └── 自述文件├── 角色│ └── 测试角色│ └── 任务│ └── main.yml└── test-play.ymlAlright,这基本上是一个解决方法。仅复制playbook附近所需的目录和从属目录(从集合目录)\n来源:\n。├── 插件│ └── 自述文件├── 角色│ └── 测试角色│ └── 任务│ └── main.yml└── test-play.yml
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
- import_role:
name: test.ansible_poc_collection.testrole
COLLECTIONS_PATHS=/home/user/tests/ansible-poc-collection/collections ansible-playbook -i 127.0.0.1, test-play.yml
.
├── plugins
│ └── README.md
├── roles
│ └── testrole
│ └── tasks
│ └── main.yml
└── test-play.yml