【发布时间】:2018-02-22 13:03:55
【问题描述】:
任务:使用 ansible-playbook 从主机组收集事实并将它们放入本地计算机上的文件中。
我的解决方案:
---
- hosts: foo
order: sorted
gather_facts: no
remote_user: foo
become: yes
become_method: sudo
tasks:
- name: gather foo hosts information
setup:
register: gathered_data
- name: write gathered information into a file
local_action: copy content="{{ gathered_data }}" dest=/foo/gathered_data.out
...
问题:一切正常,但输出文件是一大行。是否可以像ansible -m setup foo 输出一样保持文本格式?
还在为这项任务寻找更好的解决方案。 Ansible 版本:2.4.2.0
【问题讨论】:
标签: ansible ansible-2.x ansible-facts