ERROR! 角色 Users/xxxx/ansible/roles/basic_install’ 未找到。

huangapple go评论62阅读模式
英文:

ERROR! the role Users/xxxx/ansible/roles/basic_install' was not found

问题

ERROR! 角色 'Users/xxxx/ansible/roles/basic_install' 未在以下路径中找到:/Users/xxxx/ansible/playbooks/roles:/Users/xxxx/.ansible/roles:/usr/share/ansible/roles:/etc/ansible/roles:/Users/xxxx/ansible/playbooks

出现错误的位置似乎在'/Users/xxxx/ansible/playbooks/byrule.yml':第6行,第7列,但根据确切的语法问题,错误可能出现在文件的其他位置。

有问题的行似乎是:

roles:
  - role: 'Users/xxxx/ansible/roles/basic_install'
    ^ 这里

我有以下的ansible结构:

ansible/
  ansible.cfg
  inventory
  playbooks/
    byrule.yml
  rules/
    basic_install/
      tasks/
        main.yml
    full_install/
      tasks/
        main.yml

所使用的playbook的内容:

---
- name: 在Debian上基本安装软件包
  hosts: all
  become: true
  roles:
    - basic_install

- name: 在Debian上全面安装软件包
  hosts: all
  become: true
  roles:
    - full_install

最好的问候

根据错误输出,我尝试在playbook中将角色指定为路径,或将rules目录移动到playbooks目录中,但都没有成功,我仍然收到相同的错误。非常感谢任何帮助。

英文:

i am running an ansible playbook, but it won't find my defined roles. I get the following error:

ERROR! the role 'Users/xxxx/ansible/roles/basic_install' was not found in /Users/xxxx/ansible/playbooks/roles:/Users/xxxx/.ansible/roles:/usr/share/ansible/roles:/etc/ansible/roles:/Users/xxxx/ansible/playbooks

The error appears to be in '/Users/xxxx/ansible/playbooks/byrule.yml': line 6, column 7, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

  roles:
    - role: 'Users/xxxx/ansible/roles/basic_install'
      ^ here

I have the following ansible structure:


ansible/
  ansible.cfg
  inventory
  playbooks/
    byrule.yml
  rules/
    basic_install/
      tasks/
        main.yml
    full_install/
      tasks/
        main.yml

Content of the used playbook:

---
- name: Basic install of packages on Debian
  hosts: all
  become: true
  roles:
    - basic_install

- name: Full install of packages on Debian
  hosts: all
  become: true
  roles:
    - full_install

Best Regards

Based on the error output, i tried to give the rule as a path in the playbook, or move the rules directory into the playbooks directory, but none of them worked, i still get the same error. I would be very grateful for any help.

答案1

得分: 0

如果你曾经预料到这个错误,问题在于playbooks位于playbooks目录内,而默认情况下ansible会在那里查找角色。正确的方式是将playbooks与角色目录保持在相同级别。

英文:

If you ever anticipate this error, the problem is that the playbooks are inside the playbooks directory, and by default ansible looks there for the roles. The correct way is to keep the playbooks at the same level as the roles directory.

答案2

得分: 0

按照Ansible文档所述,

> 默认情况下,Ansible在以下位置查找角色:
> - 在集合中,如果您正在使用它们
> - 在名为roles/的目录中,相对于playbook文件
> - 在配置的roles_path中。默认搜索路径为~/.ansible/roles:/usr/share/ansible/roles:/etc/ansible/roles。
> - 在playbook文件所在的目录中

在运行playbook时,确保不要在playbooks目录中,而是在项目的主目录中,即在你的情况下是ansible目录。

英文:

As described in the ansible documentations

> By default, Ansible looks for roles in the following locations:
> - in collections, if you are using them
> - in a directory called roles/, relative to the playbook file
> - in the configured roles_path. The default search path is ~/.ansible/roles:/usr/share/ansible/roles:/etc/ansible/roles.
> - in the directory where the playbook file is located

when running the playbook you need to make sure not to be in the playbooks directory but in the main dir of the project - in your case the ansible dir

huangapple
  • 本文由 发表于 2023年3月31日 17:43:00
  • 转载请务必保留本文链接:https://go.coder-hub.com/75897022.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定