title: How to write a pretty JSON file from a template in ansible?
body: <p>I am trying to write a config file using jinja2 templating and save the file as .json and pretty format it.</p>
  
  <p>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.</p>
  
  <pre><code>---
  #Write config file
  - name: Deploy configuration file
    template: src=templates/config.j2 dest="C:\\SomeDir\\
  {{web_app.name}}_config.json"
  </code></pre>