【问题标题】:Ansible roles throwing error @/root/roles:/root:/etc/ansible/rolesAnsible 角色抛出错误 @/root/roles:/root:/etc/ansible/roles
【发布时间】:2016-10-17 18:01:13
【问题描述】:

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

如果我在这里遗漏了什么,请告诉我。

【问题讨论】:

  • 你的角色所在的nginx目录在哪里?
  • 它位于 /etc/ansible/roles/ngnix
  • ls -l /etc/ansible/roles/nginx/tasks/main.yml 的结果是什么?
  • 您好,/etc/ansible/roles/nginx/ 下没有创建任何内容。 root@ubuntu-96:/etc/ansible/roles/ngnix# ls -l total 0

标签: ansible


【解决方案1】:

因为 Ansible 在文件夹 /root/roles、/root、/etc/ansible/roles 或本地 ./roles 中找不到 nginx 角色。

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

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

并按照其 README.md 中的说明使用它

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-02-05
    • 2016-05-22
    • 2016-08-25
    相关资源
    最近更新 更多