“动态运行”;ansible galaxy安装-r requirement.yml-p角色;作为运行角色之前的先决条件
我试图让以下Ansible剧本发挥作用,但不知道如何告诉Ansible:“动态运行”;ansible galaxy安装-r requirement.yml-p角色;作为运行角色之前的先决条件,ansible,roles,Ansible,Roles,我试图让以下Ansible剧本发挥作用,但不知道如何告诉Ansible: 忽略对角色存在性的检查 在使用角色之前,运行ansible galaxy命令自动加载角色 这是我的密码: - name: Install prerequisite roles hosts: all become: no tasks: - name: run ansible galaxy local_action: command ansible-galaxy install -r re
- 忽略对角色存在性的检查
- 在使用角色之前,运行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
来完成上述任务,但也没有成功。我的要求.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
工具书类
git pull upstream branch
ansible-galaxy install -r path/to/rolesfile.yml -p path/to/rolesdir -f
ansible-playbook run-the-playbook.yml
在这个过程中,最有可能被遗忘的一步是中间步骤
步虽然我们可以改进流程和文档,尝试
确保不跳过此步骤,我们可以改进ansible playbook
因此,不需要执行该步骤
因此,在这项提议得到实施之前,这似乎是不可能的
工具书类
- 我也在使用requirements.yml,然后使用立即运行它们
include*
语句不可用
为了澄清,我将添加一些分号:git pull上游分支;ansible galaxy安装-r path/to/rolesfile.yml-p path/to/rolesdir-f;ansible playbook run-the-playbook.yml
- name: Get required roles with ansible galaxy
local_action: command ansible-galaxy install -r requirements.yml -p roles/
- name: Install some.role
include_role:
name: some.role