title: Ansible jinja2 template from json file
body: <p>I have a json host_names.json file with the structure of</p>
  
  <pre><code>{
   "host1": "run on host 1",
   "host2": "run on host 2",
   "host3": "run on host 3"
  }
  </code></pre>
  
  <p>In the same directory, I have a playbook run.yml</p>
  
  <pre><code>---
  - name: Run this
    connection: local
  
    tasks:
    - name: Template
       src: "template.j2"
       dest: "/my_dest/my_file.txt
  </code></pre>
  
  <p>I'd like the template to look like this:</p>
  
  <pre><code>#########
  # host1 #
  #########
  
  run on host 1
  
  end
  
  #########
  # host2 #
  #########
  
  run on host 2
  
  end 
  
  #########
  # host3 #
  #########
  
  run on host 3
  
  end 
  </code></pre>
  
  <p>How would my template look for this? This is what I currently have</p>
  
  <pre><code>{% for a, b in host_names %}
  ###########
  # {{ a }} #
  ###########
  
  {{ b }}
  
  end
  
  {% endfor %}
  </code></pre>