2017-07-24 161 views
0

是否有一些文件模块,将允许读取文件,过滤其内容并将更改的文件存储在一个任务?像Ansible模块来过滤文件内容

- shell: cat /path/file.txt 
    register: file_content 
- copy: 
    content: "{{ file_content.stdout | from_json | to_nice_json(indent=4) }}" 
    dest: "/path/file.txt" 

但在单个任务?

回答

0

不,您可能会write your own module,或使用shell命令与jq

- shell: cat /path/file.txt | jq '.' --indent 4 > /path/file.txt