当我运行以下Ansible命令时:
$ ansible-playbook deploy/solo/wifi.yml -i inventories/solo
我收到以下错误消息:
ERROR! the role 'solo/controller/wifi' was not found in /home/peng/git/uavops/deploy/roles:/home/peng/.ansible/roles:/usr/share/ansible/roles:/etc/ansible/roles:/home/peng/git/uavops/deploy
The error appears to be in '/home/peng/git/uavops/deploy/wifi.yml': line 5, column 7, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
roles:
- solo/controller/wifi
^ here
这是怎么发生的?我在工作目录下调用ansible-playbook
。然而,Ansible-Playbook忽略了它,并尝试在目录中找到角色。我如何告诉我们可以找到正确的角色目录?
toby默认,Ansible在两个位置的角色外观:
/home/peng/git/uavops
/home/peng/git/uavops/deploy
配置选项,以便可以找到您的角色。将共享角色检查到单个位置使它们更易于在多个剧本中使用。有关管理设置的详细信息,请参见
,您可以用完全合格的道路呼唤角色:
roles/ # in a directory called relative to the playbook file
/etc/ansible/roles
roles_path
以告诉易于搜索角色。
在你的案件中,您应该将角色移到一个名为
ansible.cfg
或使用绝对路径到达角色:
---
- hosts: webservers
roles:
- role: '/path/to/my/roles/common'
roles_path
指向所需的位置。