Ansible可以从收藏中找到角色
I got collection that has structure
namespace/
── collectionA/
├── docs/
├── galaxy.yml
├── README.md
└── roles/
├── roleA/
| └── tasks/
| ├──taskA.yml
| ├──taskB.yml
└── roleB/
└── tasks/
├──taskA.yml
├──taskB.yml
according to using collections if I wan to use that roles all I have to do is include_role with fqdn
- hosts: all
collections:
- my_namespace.my_collection
tasks:
- import_role:
name: role1
but it seems not working.我仍然有错误:
错误!在edaas.post_provisioning:ansible.legacy:/home/home/jenkins/agent/workspace/create_infra/playbooks/角主页/jenkins/agent/workspace/create_infra/playbooks 12:10:53
12:10:53错误似乎在'/home/jenkins/agent/workspace/create_infra/playbooks/ansible_main_initial.yml':第24行,第15列,但5月, 12:10:53文件中的其他位置取决于确切的语法问题。 12:10:53
12:10:53有问题的线似乎是: 12:10:53
12:10:53 -ansible.builtin.import_role: 12:10:53名称:Manage_users 12:10:53 ^这里
Collection is installed correctly - checked by ansible-galaxy collection list
Any idea what can be still wrong?角色名称与规则(小写和只有_的字符)对齐 收集安装在/home/cirunner/.ansible/collections中
Ansible [core 2.11.12] config file =无配置的模块 搜索路径= ['/home/cirunner/.ansible/plugins/modules', '/usr/share/ansible/ansible/插件/模块'] Ansible Python模块位置 =/usr/local/lib/python3.8/dist-packages/sible Ansible收集位置= /HOME/cirunner/.ansible/collections/collections operable位置= /usr/local/bin/ansible Python版本= 3.8.0(默认,12月9日,2021年, 17:53:27)[GCC 8.4.0] Jinja版本= 3.1.2 Libyaml = true
I got collection that has structure
namespace/
── collectionA/
├── docs/
├── galaxy.yml
├── README.md
└── roles/
├── roleA/
| └── tasks/
| ├──taskA.yml
| ├──taskB.yml
└── roleB/
└── tasks/
├──taskA.yml
├──taskB.yml
according to using collections if I wan to use that roles all I have to do is include_role with fqdn
- hosts: all
collections:
- my_namespace.my_collection
tasks:
- import_role:
name: role1
but it seems not working. I still get error:
ERROR! the role 'manage_users' was not found in edaas.post_provisioning:ansible.legacy:/home/jenkins/agent/workspace/Create_Infra/playbooks/roles:/home/cirunner/.ansible/roles:/usr/share/ansible/roles:/etc/ansible/roles:/home/jenkins/agent/workspace/Create_Infra/playbooks
12:10:53
12:10:53 The error appears to be in '/home/jenkins/agent/workspace/Create_Infra/playbooks/ansible_main_initial.yml': line 24, column 15, but may
12:10:53 be elsewhere in the file depending on the exact syntax problem.
12:10:53
12:10:53 The offending line appears to be:
12:10:53
12:10:53 - ansible.builtin.import_role:
12:10:53 name: manage_users
12:10:53 ^ here
Collection is installed correctly - checked by ansible-galaxy collection list
Any idea what can be still wrong? Role names are aligned to rules (lowercase and only characters with _
Collection is installed in /home/cirunner/.ansible/collections
ansible [core 2.11.12] config file = None configured module
search path = ['/home/cirunner/.ansible/plugins/modules',
'/usr/share/ansible/plugins/modules'] ansible python module location
= /usr/local/lib/python3.8/dist-packages/ansible ansible collection location = /home/cirunner/.ansible/collections executable location =
/usr/local/bin/ansible python version = 3.8.0 (default, Dec 9 2021,
17:53:27) [GCC 8.4.0] jinja version = 3.1.2 libyaml = True
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我遇到了这个线程,我的问题是我的角色名称中有连字符,根据找到的文档在这里。
更改为角色名称中的下指数解决了问题。
I came across this thread, and my issue was I had hyphens in my role name, which is not supported as per the documentation found here.
Changing to underscores in the role name resolved the issue.
我知道这很旧,但是我也有一个类似的问题,我花了几个小时才找到自己的问题。也许我想出的方式会帮助别人。
我的问题是我项目目录中的某些测试中留下的一个空收集目录
< project_dir>/collections/ansible_collection/my_namespace/my_collection
目录。Ansible-galaxy
找到了包含/usr/share/ansible/collections
的真实安装集合,并将其报告为已安装,一切正常。但是
Ansible-Playbook
首先在我的项目目录中找到了空目录,并将其解释为收集位置,并且不远地查看/usr/usr/usr/share/ansible/collections中的实际安装集合
。So, how I figured it out and how you might be able to figure out your problem:
ansible-playbook ... -vvvv
Loading collection my_namespace.my_collection from/collections/ansible_collections/my_namespace/my_collection
I hope it helps.
I know this is old but I had a similar issue and it took me hours to find my problem. Maybe the way I figured it out will help someone else.
My problem was an empty collection directory left over from some tests in my project directory
<project_dir>/collections/ansible_collection/my_namespace/my_collection
directory.ansible-galaxy
found the real installed collection containing the role in/usr/share/ansible/collections
and reported it as installed and everything fine.But
ansible-playbook
found the empty directory in my project directory first and interpreted this as the collection location and didn't look further to the actual installed collection in/usr/share/ansible/collections
.So, how I figured it out and how you might be able to figure out your problem:
ansible-playbook ... -vvvv
Loading collection my_namespace.my_collection from <project_dir>/collections/ansible_collections/my_namespace/my_collection
I hope it helps.