# copy j2 file to Json on windows server

**URL:** <https://forum.ansible.com/t/copy-j2-file-to-json-on-windows-server/32795>\
**Category:** Ansible Project\
**Tags:** windows\
**Created:** [April 28, 2020, 1:56am UTC](https://forum.ansible.com/t/copy-j2-file-to-json-on-windows-server/32795 "2020-04-28T01:56:00Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![shyam.rpms](https://avatars.discourse-cdn.com/v4/letter/s/a88e57/32.png) [@shyam.rpms](https://forum.ansible.com/u/shyam.rpms)\
**Post date:** [April 28, 2020, 1:56am UTC](https://forum.ansible.com/t/copy-j2-file-to-json-on-windows-server/32795/1 "2020-04-28T01:56:00Z")

</div>

Hi,

Im trying to create a json file using jinja2 template using the following play. The file is not creating and not giving any error. can any one help.

**- name: creating a config file**  
**win\_copy:**  
**content: “{{ lookup(‘template’,‘config.j2’) | to\_nice\_json }}”**  
**dest: “D:\config1.json”**  
**remote\_src: true**

**Thank you,**  
**Shyam**

---

<div class="post-metadata">

**Author:** ![jborean](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/jborean/32/1525_2.png) [@jborean](https://forum.ansible.com/u/jborean)\
**Post date:** [April 28, 2020, 9:22am UTC](https://forum.ansible.com/t/copy-j2-file-to-json-on-windows-server/32795/2 "2020-04-28T09:22:27Z")

</div>

Remove remote\_src: true as it’s expecting you to supply src for the copy. Better yet use win\_template instead like

`

- win\_template:  
src: config.j2  
dest: D:\config1.json

`

---

<div class="post-metadata">

**Author:** ![shyam.rpms](https://avatars.discourse-cdn.com/v4/letter/s/a88e57/32.png) [@shyam.rpms](https://forum.ansible.com/u/shyam.rpms)\
**Post date:** [April 28, 2020, 2:03pm UTC](https://forum.ansible.com/t/copy-j2-file-to-json-on-windows-server/32795/3 "2020-04-28T14:03:45Z")

</div>

Hi Jordan,

I have tried the suggested code but still have the same issue and it is not creating the file or updating the file content.

- win\_template:  
src: config.j2  
dest: D:\config1.json

Thanks and Regards,  
Shyam

---

<div class="post-metadata">

**Author:** ![Dick\_Visser](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@Dick\_Visser](https://forum.ansible.com/u/Dick_Visser)\
**Post date:** [April 28, 2020, 2:32pm UTC](https://forum.ansible.com/t/copy-j2-file-to-json-on-windows-server/32795/4 "2020-04-28T14:32:56Z")

</div>

Please post a full debug log using -vvv

---

<div class="post-metadata">

**Author:** ![shyam.rpms](https://avatars.discourse-cdn.com/v4/letter/s/a88e57/32.png) [@shyam.rpms](https://forum.ansible.com/u/shyam.rpms)\
**Post date:** [April 28, 2020, 6:10pm UTC](https://forum.ansible.com/t/copy-j2-file-to-json-on-windows-server/32795/5 "2020-04-28T18:10:11Z")

</div>

Hi,

Im using Ansible tower and j2 file and playbook are in GitHub, can you please check the attached log,

Thank you,  
shyam

> **(attachments)**
>
> ![log1.PNG](https://us1.discourse-cdn.com/ansible/original/2X/2/27f25a29116c0ace3d8f7c9a6eb5f118062c2b47.png)

---

<div class="post-metadata">

**Author:** ![Dick\_Visser](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@Dick\_Visser](https://forum.ansible.com/u/Dick_Visser)\
**Post date:** [April 28, 2020, 6:43pm UTC](https://forum.ansible.com/t/copy-j2-file-to-json-on-windows-server/32795/6 "2020-04-28T18:43:47Z")

</div>

I see a photograph of a screen that displays a non verbose playbook run without any useful information.

Please contact Redhat for support with Tower.

---

<div class="post-metadata">

**Author:** ![racke](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/racke/32/4767_2.png) [@racke](https://forum.ansible.com/u/racke)\
**Post date:** [April 28, 2020, 6:44pm UTC](https://forum.ansible.com/t/copy-j2-file-to-json-on-windows-server/32795/7 "2020-04-28T18:44:01Z")

</div>

> Hi,
> 
> Im using Ansible tower and j2 file and playbook are in GitHub, can you please check the attached log,
> 
> Thank you,  
> shyam

Ansible tower is not a subject of this list, only Ansible itself.  
Please contact RedHat support.

Regards  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Racke

---

<div class="post-metadata">

**Author:** ![jborean](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/jborean/32/1525_2.png) [@jborean](https://forum.ansible.com/u/jborean)\
**Post date:** [April 28, 2020, 8:58pm UTC](https://forum.ansible.com/t/copy-j2-file-to-json-on-windows-server/32795/8 "2020-04-28T20:58:14Z")

</div>

The output shows a change occured and the file was templated. If the contents weren’t what you were expecting then you need to fix the template or make sure you are checking the right server.

---

<div class="post-metadata">

**Author:** ![shyam.awk](https://avatars.discourse-cdn.com/v4/letter/s/9d8465/32.png) [@shyam.awk](https://forum.ansible.com/u/shyam.awk)\
**Post date:** [April 29, 2020, 10:04am UTC](https://forum.ansible.com/t/copy-j2-file-to-json-on-windows-server/32795/9 "2020-04-29T10:04:32Z")

</div>

Hi,

Thanks it’s working fine now.

Thank you,  
Shyam
