Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/110.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
“动态运行”;ansible galaxy安装-r requirement.yml-p角色;作为运行角色之前的先决条件_Ansible_Roles - Fatal编程技术网

“动态运行”;ansible galaxy安装-r requirement.yml-p角色;作为运行角色之前的先决条件

“动态运行”;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剧本发挥作用,但不知道如何告诉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
来完成上述任务,但也没有成功。我的
要求.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
工具书类

我收到了Ansible开发团队的以下回复

@slmingol这个特殊的错误是设计造成的。角色和任务是 在执行其中任何一项之前预加载。我们正在提出建议 他们从不同的角度解决了这个问题,但没有一个是这样的 尚未被接受或书写

他还提到这项建议:

将最新(甚至特定)版本的剧本与 对于适当的角色,通常需要以下步骤:

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