我想在一个单一的任务中运行多个循环

问题描述

我有一个条件,它将检查我的os_system和来宾名称,并且我已经用过with_together,对于这个循环,现在我想根据with_together所满足的条件运行另一个循环,但是我不能所以。 请看一下我的代码

代码

    - name: copy files to vm
      vmware_guest_file_operation:
           hostname: "{{ vc_name }}"
           username: "{{ myuser }}"
           password: "{{ mypass }}"
           datacenter: ha-datacenter
           vm_id: "{{ item.0 }}"
           vm_username: root
           vm_password: "{{ guest_password }}"
           validate_certs: no
           copy:
             src: "{{ item.src }}"
             dest: "{{ item.dest }}"
             overwrite: False
      with_items:
           - { src: /home/xxxx/sites/scripts/Centos_8/fil1.txt,dest: /tmp/file1.txt}
           - { src: /home/pxxxx/sites/scripts/Centos_8/file2.txt,dest: /tmp/file2.txt}
      when:
       - 'item.1|string == "2"  or item.1|string == "3"'
       - 'item.2|string > "20"'
      with_together:
         - "{{ g_name }}"
         - "{{ o_name }}"
         - "{{ hd }}"

我想做的是,首先,我的代码将在条件满足后跟随with_together循环,然后将多个文件复制到该特定的VM,使用with_items循环。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)