我试图让以下Ansible剧本工作,但无法弄清楚如何告诉Ansible:
-
忽略检查是否存在角色
-
运行ansible-galaxy命令以在使用之前自动加载角色
这是我的代码:
- name: Install prerequisite roles
hosts: all
become: no
tasks:
- name: run ansible galaxy
local_action: command ansible-galaxy install -r requirements.yml -p roles/
- name: Install Oracle Java
hosts: tomcat-servers:ss-servers:ns-servers:ld-servers
become: yes
roles:
- raltd-jdk
我也尝试使用 pre_tasks
进行上述操作,但也无法正常工作 . 我的 requirements.yml
就是这样的:
- src: git@gitserver.mydom.com:ansible/raltd-jdk.git
scm: git
我收到这个错误:
$ ansible-playbook -i inv/myinventory raltd-jdk.yml
ERROR! the role 'raltd-jdk' was not found in /path/to/ansible/roles:/etc/ansible/roles:/path/to/ansible
The error appears to have been in '/path/to/ansible/raltd-jdk.yml': line 16, column 7, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
roles:
- raltd-jdk
^ here
2 回答
我收到了Ansible开发团队的以下回复 .
他还提到了这个提议:Proposal: Auto Install Ansible Roles
因此,在该提案得到实施之前,这似乎是不可能的 .
参考文献
我也在使用requirements.yml,然后使用include_role立即运行它们 .
include*
陈述是processed as they are encountered .