Ansible – Template: to_nice_json

In order to create a file from the template and immediately save it as “Pretty JSON“, you can use the “copy” module with the “content” key. For example, save the template “config.j2” as the file “/app/config.json” Playbook: