将_fileglob与Ansible剧本中的另一个列表结合

将_fileglob与Ansible剧本中的另一个列表结合,ansible,ansible-playbook,Ansible,Ansible Playbook,因此,我有一个Ansible playbook,我试图为列表中的每个项目调用一个命令,但也在fileglob上运行该命令。Ansible中有一个“with_nested”,它可以接受变量名,但如果我添加一个“with_fileglob”,它只会插入“with_fileglob”作为文件名,而不是实际执行glob vars: repo_versions: - version: trusty distribution: Ubuntu - versi

因此,我有一个Ansible playbook,我试图为列表中的每个项目调用一个命令,但也在fileglob上运行该命令。Ansible中有一个“with_nested”,它可以接受变量名,但如果我添加一个“with_fileglob”,它只会插入“with_fileglob”作为文件名,而不是实际执行glob

  vars:
    repo_versions:
      - version: trusty
        distribution: Ubuntu
      - version: wheezy
        distribution: Debian

  ...

  - command: reprepro -b /var/www/html includedeb {{ item[0].version }} {{ item[1] }}
    with_nested:
      - repo_versions
      with_fileglob: /home/repoman/debs/*.deb
    when: debs_available.stat.exists == True

我尝试了两种不同的组合,但似乎无法让它在双for循环中处理命令(对于每个.version,对于每个.deb文件)

这应该是您正在尝试完成的

我使用
shell
模块注册fileglob的输出,然后在循环中注册registerd变量的
stdout\u lines
属性。我已将测试中的任务转换为实际的命令和路径,因此您可能需要再次检查:

  vars:
    repo_versions:
      - version: trusty
        distribution: Ubuntu
      - version: wheezy
        distribution: Debian

  tasks:
    - shell: ls -1 /home/repoman/debs/*.deb
      register: repo_list

    - command: reprepro -b /var/www/html includedeb {{ item[0].version }} {{ item[1] }}
      with_nested:
        - repo_versions
        - repo_list.stdout_lines

这应该是你正在努力实现的目标

我使用
shell
模块注册fileglob的输出,然后在循环中注册registerd变量的
stdout\u lines
属性。我已将测试中的任务转换为实际的命令和路径,因此您可能需要再次检查:

  vars:
    repo_versions:
      - version: trusty
        distribution: Ubuntu
      - version: wheezy
        distribution: Debian

  tasks:
    - shell: ls -1 /home/repoman/debs/*.deb
      register: repo_list

    - command: reprepro -b /var/www/html includedeb {{ item[0].version }} {{ item[1] }}
      with_nested:
        - repo_versions
        - repo_list.stdout_lines

这应该是你正在努力实现的目标

我使用
shell
模块注册fileglob的输出,然后在循环中注册registerd变量的
stdout\u lines
属性。我已将测试中的任务转换为实际的命令和路径,因此您可能需要再次检查:

  vars:
    repo_versions:
      - version: trusty
        distribution: Ubuntu
      - version: wheezy
        distribution: Debian

  tasks:
    - shell: ls -1 /home/repoman/debs/*.deb
      register: repo_list

    - command: reprepro -b /var/www/html includedeb {{ item[0].version }} {{ item[1] }}
      with_nested:
        - repo_versions
        - repo_list.stdout_lines

这应该是你正在努力实现的目标

我使用
shell
模块注册fileglob的输出,然后在循环中注册registerd变量的
stdout\u lines
属性。我已将测试中的任务转换为实际的命令和路径,因此您可能需要再次检查:

  vars:
    repo_versions:
      - version: trusty
        distribution: Ubuntu
      - version: wheezy
        distribution: Debian

  tasks:
    - shell: ls -1 /home/repoman/debs/*.deb
      register: repo_list

    - command: reprepro -b /var/www/html includedeb {{ item[0].version }} {{ item[1] }}
      with_nested:
        - repo_versions
        - repo_list.stdout_lines

我很确定你不能在这样的循环中使用with_x,但是你可以让文件列表在前一个任务的变量中注册,然后用嵌套的with_将其提供给。我很确定你不能在这样的循环中使用with_x,但是你可以让文件列表在前一个任务的变量中注册,我很确定你不能在这样的循环中使用with_x,但是你可以在前一个任务的变量中注册文件列表,并将其输入with_nested。我很确定你不能在这样的循环中使用with_x,但是你可以在前一个任务的变量中注册文件列表,然后用_-nested给它喂食。