How to write a pretty JSON file from a template in ansible?

Viewed 13031

I am trying to write a config file using jinja2 templating and save the file as .json and pretty format it.

How can I save the output file as a variable and then format it to JSON using to_nice_json? This play is part of a role that is called from another main playbook. Currently it writes the config file to a Windows host but it's not formatted as JSON.

---
#Write config file
- name: Deploy configuration file
  template: src=templates/config.j2 dest="C:\\SomeDir\\
{{web_app.name}}_config.json"
1 Answers
Related