调用角色的dir参数

时间:2016-11-28 18:58:46

标签: ansible ansible-playbook

我的剧本中有这一点。

 roles:
  - {role: cleanup-create, dir: '/standard/', commit: "{{choice}}"}

文件结构是/roles/standard/cleanup-create/tasks/main.yml

然而我收到了这个错误:

ERROR! the role 'cleanup-create' was not found in /home/myuser/network-ansible-myuser/roles:/home/myuser/network-ansible-myuser:/etc/ansible/roles

The error appears to have been in '/home/myuser/network-ansible-myuser/configure-files.yml': line 15, column 5, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

  roles:
  - {role: cleanup-create, dir: '/standard', commit: "{{choice}}"}
    ^ here

现在,错误消息似乎是说我的角色在/ roles中找不到。但是dir参数应该使它看起来在/ roles / standard下。

5分钟前它正在工作,我发誓!

2 个答案:

答案 0 :(得分:0)

角色没有dir特殊参数 它只是一个普通变量,与您的示例中的commit相同。

您应该将所有角色直接放在./roles文件夹中,而不进行任何嵌套。

答案 1 :(得分:0)

您实际上可以在roles_path中设置ansible.cfg configuration variable(或者pass it in the command line - 尝试一下,我不确定您是否可以使用{{1}执行此操作})。

来自doc:

  

角色路径指示要搜索以查找Ansible角色的Playbook项目的roles_path子目录之外的其他目录

./首先搜索playbook目录中的角色,然后检查其他路径。

您可以指定多个目录以在

中查找角色
roles/
相关问题