copy j2 file to Json on windows server

17 views
Skip to first unread message

shyam rpm

unread,
Apr 27, 2020, 9:56:00 PM4/27/20
to Ansible Project
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

Jordan Borean

unread,
Apr 28, 2020, 5:22:27 AM4/28/20
to Ansible Project
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


shyam rpm

unread,
Apr 28, 2020, 10:04:24 AM4/28/20
to ansible...@googlegroups.com
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

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/8c3816e3-703c-490a-a591-ed7256bf0c59%40googlegroups.com.

Dick Visser

unread,
Apr 28, 2020, 10:33:33 AM4/28/20
to ansible...@googlegroups.com
Please post a full debug log using -vvv 

--
Sent from a mobile device - please excuse the brevity, spelling and punctuation.

shyam rpm

unread,
Apr 28, 2020, 2:10:56 PM4/28/20
to ansible...@googlegroups.com
Hi, 

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

Thank you,
shyam

Virus-free. www.avast.com


Virus-free. www.avast.com
log1.PNG

Dick Visser

unread,
Apr 28, 2020, 2:44:19 PM4/28/20
to ansible...@googlegroups.com
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. 



Stefan Hornburg (Racke)

unread,
Apr 28, 2020, 2:44:35 PM4/28/20
to ansible...@googlegroups.com
On 4/28/20 8:10 PM, shyam rpm wrote:
> 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
Racke

>
> <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
> Virus-free. www.avast.com
> <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
>
> <#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
>
> On Tue, Apr 28, 2020 at 8:03 PM Dick Visser <dick....@geant.org <mailto:dick....@geant.org>> wrote:
>
> Please post a full debug log using -vvv 
>
> On Tue, 28 Apr 2020 at 16:04, shyam rpm <shyam...@gmail.com <mailto:shyam...@gmail.com>> wrote:
>
> 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
>
> On Tue, Apr 28, 2020 at 2:52 PM Jordan Borean <jbor...@gmail.com <mailto:jbor...@gmail.com>> wrote:
>
> 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
> |
>
>
> --
> You received this message because you are subscribed to the Google Groups "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to
> ansible-proje...@googlegroups.com <mailto:ansible-proje...@googlegroups.com>.
> <https://groups.google.com/d/msgid/ansible-project/8c3816e3-703c-490a-a591-ed7256bf0c59%40googlegroups.com?utm_medium=email&utm_source=footer>.
>
> --
> You received this message because you are subscribed to the Google Groups "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to
> ansible-proje...@googlegroups.com <mailto:ansible-proje...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/CAFXETnrs6%2B8%2B%2BiRLiL3%3DCZNfh7smjFM%3DGmca%3D5PgaP81pfhSNw%40mail.gmail.com
> <https://groups.google.com/d/msgid/ansible-project/CAFXETnrs6%2B8%2B%2BiRLiL3%3DCZNfh7smjFM%3DGmca%3D5PgaP81pfhSNw%40mail.gmail.com?utm_medium=email&utm_source=footer>.
>
> --
> Sent from a mobile device - please excuse the brevity, spelling and punctuation.
>
> --
> You received this message because you are subscribed to the Google Groups "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to
> ansible-proje...@googlegroups.com <mailto:ansible-proje...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/CAL8fbwO9RkgyEyFS95kXfpV5jfgjGk_iJXEz1yujYCJCHY0hNg%40mail.gmail.com
> <https://groups.google.com/d/msgid/ansible-project/CAL8fbwO9RkgyEyFS95kXfpV5jfgjGk_iJXEz1yujYCJCHY0hNg%40mail.gmail.com?utm_medium=email&utm_source=footer>.
>
>
> <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
> Virus-free. www.avast.com
> <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
>
> <#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
>
> --
> You received this message because you are subscribed to the Google Groups "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to
> ansible-proje...@googlegroups.com <mailto:ansible-proje...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/CAFXETnpsKs4R_bQMTcBkH-mDRGCSBqatbu_tSNFYqJ1V%3DLeCWA%40mail.gmail.com
> <https://groups.google.com/d/msgid/ansible-project/CAFXETnpsKs4R_bQMTcBkH-mDRGCSBqatbu_tSNFYqJ1V%3DLeCWA%40mail.gmail.com?utm_medium=email&utm_source=footer>.


--
Ecommerce and Linux consulting + Perl and web application programming.
Debian and Sympa administration. Provisioning with Ansible.

signature.asc

Jordan Borean

unread,
Apr 28, 2020, 4:58:14 PM4/28/20
to Ansible Project
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.

syam rhel

unread,
Apr 29, 2020, 6:05:01 AM4/29/20
to ansible...@googlegroups.com
Hi, 

Thanks it's working fine now.

Thank you,
Shyam

On Wed, Apr 29, 2020, 2:28 AM Jordan Borean <jbor...@gmail.com> wrote:
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.

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/8529201d-3719-4550-9677-9fec0d41523d%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages