Ansible 将变量传递到文件中的行 stdout_lines
Ansible Passing variable to line in file with stdout_lines
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 }}"
如何让 output3.stdout_lines 成为订单项?我目前的方法复制了我不想要的整个东西。
试试这个:
- name: Copy File to Local Machine
local_action: lineinfile dest=/Users/{{inventory_hostname}} line="{{item.1}}"
with_subelements:
- "{{output3.results}}"
- stdout_lines
- flags:
skip_missing: yes
我想这是一些没有 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 }}"
如何让 output3.stdout_lines 成为订单项?我目前的方法复制了我不想要的整个东西。
试试这个:
- name: Copy File to Local Machine
local_action: lineinfile dest=/Users/{{inventory_hostname}} line="{{item.1}}"
with_subelements:
- "{{output3.results}}"
- stdout_lines
- flags:
skip_missing: yes
我想这是一些没有 Python 支持的硬件盒?
否则还有更优雅的方式来获取文件。