我是Ansible的新手,我已经创建了我的第一个Ansible角色剧本,当我试图运行它时,它会抛出下面的错误,而其他模块除了角色(如处理程序,模板)都工作得很好。我只在剧本中的角色中观察到这个问题。
---
- hosts: webservers
roles:
- nginx
ERROR! the role 'nginx' was not found in /root/roles:/root:/etc/ansible/roles
The error appears to have been in '/root/server.yml': line 4, column 7, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
roles:
- nginx
^ here
在ansible.cng
文件中,我将路径指定为roles_path = /etc/ansible/roles
如果我遗漏了什么,请告诉我。
因为Ansible在/root/roles,/root,/etc/Ansible/roles或local ./roles文件夹中没有找到nginx角色
如果你想使用一个名为nginx的角色,ansible会尝试加载一个文件nginx/tasks/main。
复制以下代码到你的nginx角色文件夹:https://github.com/jdauphant/ansible-role-nginx
并按照它的README.md