不可使用的播放书搜索错误目录中的角色!如何纠正它?

问题描述 投票:0回答:1

当我运行以下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

ansible ansible-role
1个回答
3
投票
/home/peng/git/uavops/deploy

配置选项,以便可以找到您的角色。将共享角色检查到单个位置使它们更易于在多个剧本中使用。有关管理设置的详细信息,请参见

,您可以用完全合格的道路呼唤角色:

roles/ # in a directory called relative to the playbook file /etc/ansible/roles

您可以在库存文件中设置roles_path以告诉易于搜索角色。
在你的案件中,

您应该将角色移到一个名为

ansible.cfg

playbook的目录中。

或使用绝对路径到达角色:

---
- hosts: webservers
  roles:
    - role: '/path/to/my/roles/common'

    或使用
  1. roles_path

    指向所需的位置。

    
        

最新问题
© www.soinside.com 2019 - 2025. All rights reserved.