Ansible使用标准输出行将变量传递到文件中的行

Ansible使用标准输出行将变量传递到文件中的行,ansible,ansible-playbook,ansible-2.x,Ansible,Ansible Playbook,Ansible 2.x,如何将output3.stdout\u行作为行项目?我目前使用的方法复制了我不想要的全部内容 试试这个: name: the file raw: cat "{{item}}" with_items: "{{groups['firewall']}}" when: inventory_hostname == item register: output3 debug: var=output3.results name: Copy File to Local Mach

如何将output3.stdout\u行作为行项目?我目前使用的方法复制了我不想要的全部内容

试试这个:

name: the file
    raw: cat "{{item}}"
    with_items: "{{groups['firewall']}}"
    when: inventory_hostname == item
    register: output3

debug: var=output3.results

name: Copy File to Local Machine
    local_action: lineinfile dest=/Users/{{inventory_hostname}} line="{{item}}"
    with_dict: "{{ output3 }}"
我想这是一个没有Python支持的硬件盒?
否则,还有更优雅的方法来获取文件。

试试以下方法:

name: the file
    raw: cat "{{item}}"
    with_items: "{{groups['firewall']}}"
    when: inventory_hostname == item
    register: output3

debug: var=output3.results

name: Copy File to Local Machine
    local_action: lineinfile dest=/Users/{{inventory_hostname}} line="{{item}}"
    with_dict: "{{ output3 }}"
我想这是一个没有Python支持的硬件盒?

除此之外,还有更优雅的方式获取文件。

谢谢这帮了大忙。谢谢这帮了大忙。