调用角色的dir参数 [英] the dir parameter for calling roles

查看:91
本文介绍了调用角色的dir参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在剧本中有这方面的内容.

I've got this bit in my playbook.

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

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

The file structure is /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下.

Now, the error message seems to be saying my role wasn't found in /roles. However the dir parameter should make it look under /roles/standard.

我发誓5分钟前就开始工作了!

It was working 5 minutes ago, I swear!

推荐答案

您实际上可以设置roles_path ansible.cfg中的="nofollow noreferrer">配置变量(或在命令行中传递-试试看,我不确定是否可以通过roles_path来实现.

You can actually set roles_path configuration variable in ansible.cfg (or maybe pass it in the command line - try it, I'm not sure if you can do this with roles_path).

来自文档:

角色路径指示剧本项目的roles/子目录之外的其他目录,以进行搜索以查找Ansible角色

The roles path indicate additional directories beyond the roles/ subdirectory of a playbook project to search to find Ansible roles

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

./roles from playbook directory will be searched first, then additional paths will be checked.

您可以指定多个目录来查找角色

You can specify multiple directories to look for roles in

roles_path=/var/opt/my_roles:/var/opt/more_roles

这篇关于调用角色的dir参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆