gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-02 03:11:01 30 4
gpt4 key购买 nike

我是 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 或本地 ./roles 中找不到 nginx 角色。

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

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

并按照其 README.md 中的描述使用它

关于Ansible角色抛出错误@/root/roles :/root:/etc/ansible/roles,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40092826/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com