Ansible角色抛出错误@ / root / roles:/ root:/ etc / ansible / roles

时间:2016-10-17 18:01:13

标签: ansible

我是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

如果我在这里遗失任何东西,请告诉我。

1 个答案:

答案 0 :(得分:1)

因为Ansible在文件夹/ root / roles,/ root,/ etc / ansible / roles或local。/roles中找不到nginx角色。

如果您想使用名为nginx的角色,ansible将尝试在您的一个角色文件夹中加载文件nginx / tasks / main.yml。

将此代码复制到您的nginx角色文件夹中:https://github.com/jdauphant/ansible-role-nginx

按照其README.md

中的描述使用它
相关问题