Inject JSON file using URI

6 views
Skip to first unread message

Renato Marcandier

unread,
Jun 14, 2020, 2:22:36 PM6/14/20
to Ansible Project
hey guys,

I need to inject a .json file into an application using ansible.
I know that we have a module called URI. However this application accepts only by Content-Type: "application/x-www-form-urlencoded" ... in this case, I can't use "src:file.json"  Is that correct? ..

Do I need to create a variable file with all data and pass it using "body: {{ fields }}"?


Thank you

Regards
RG

Dick Visser

unread,
Jun 14, 2020, 2:33:47 PM6/14/20
to ansible...@googlegroups.com
On Sun, 14 Jun 2020 at 20:22, Renato Marcandier
<renato.m...@gmail.com> wrote:
>
> hey guys,
>
> I need to inject a .json file into an application using ansible.
> I know that we have a module called URI. However this application accepts only by Content-Type: "application/x-www-form-urlencoded" ... in this case, I can't use "src:file.json" Is that correct? ..

Not sure - but what combination(s) did you try, and what was the outcome?

>
> Do I need to create a variable file with all data and pass it using "body: {{ fields }}"?

The docs indicate that file uploads should be done using 'src':
https://docs.ansible.com/ansible/latest/modules/uri_module.html#parameter-src
But you can override headers:
https://docs.ansible.com/ansible/latest/modules/uri_module.html#parameter-headers

This combination should do what you want.

--
Dick Visser
Trust & Identity Service Operations Manager
GÉANT
Reply all
Reply to author
Forward
0 new messages