uri module - POST files

116 views
Skip to first unread message

Mark Olliver

unread,
Feb 4, 2015, 1:48:41 PM2/4/15
to ansible...@googlegroups.com
Hi,

I have the following line but i fear the uri module is not encoding the file first and thus fails to send the file. I tried to set a variable via a command and uuencode but that also failed - any ideas or do i need to shell and use curl to post?

- uri: url=http://localhost:8080/store.json method=POST body="{{ lookup('file','test') }}" status_code=200 HEADER_Content-Type="application/json" 

test is a json file.

Thanks

Mark

Giovanni Tirloni

unread,
Feb 4, 2015, 2:04:43 PM2/4/15
to ansible...@googlegroups.com
On Wed, 04 Feb 2015 18:48 +0000, Mark Olliver <ma...@olliver.me.uk>
wrote:
Hi Olivier,

What's the error and what do you get on the server's logs?

Giovanni

Mark Olliver

unread,
Feb 4, 2015, 3:16:55 PM2/4/15
to ansible...@googlegroups.com

It does not get that far instead ansible tried to parse it and objects to duplicate values which is valid in this case.

--
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 post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/1423076675.33876.223141489.119A3E6B%40webmail.messagingengine.com.
For more options, visit https://groups.google.com/d/optout.

Romeo Theriault

unread,
Feb 5, 2015, 2:27:03 PM2/5/15
to ansible...@googlegroups.com
Also, if your run the playbook in verbose mode, you'll see what ansible is sending. This can help you determine what might be wrong with the sent data. 

Also, use the 'return_content=yes' on the task to see what the server is responding.

Showing us those two things can help you troubleshoot...


Giovanni

--
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 post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/1423076675.33876.223141489.119A3E6B%40webmail.messagingengine.com.
For more options, visit https://groups.google.com/d/optout.



--
Romeo

Romeo Theriault

unread,
Feb 5, 2015, 2:28:37 PM2/5/15
to ansible...@googlegroups.com
Can you show us the output.... I'm guessing it's probably some kind of quoting/yaml parsing issue.

On Wed, Feb 4, 2015 at 10:16 AM, Mark Olliver <pixi...@gmail.com> wrote:

It does not get that far instead ansible tried to parse it and objects to duplicate values which is valid in this case.

On 4 Feb 2015 19:04, "Giovanni Tirloni" <g...@gtirloni.com> wrote:
On Wed, 04 Feb 2015 18:48 +0000, Mark Olliver <ma...@olliver.me.uk>
wrote:
> Hi,
>
> I have the following line but i fear the uri module is not encoding the
> file first and thus fails to send the file. I tried to set a variable via
> a
> command and uuencode but that also failed - any ideas or do i need to
> shell
> and use curl to post?
>

> lookup('file','test') }}" status_code=200
> HEADER_Content-Type="application/json"
>
> test is a json file.

Hi Olivier,

 What's the error and what do you get on the server's logs?

Giovanni

--
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 post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/1423076675.33876.223141489.119A3E6B%40webmail.messagingengine.com.
For more options, visit https://groups.google.com/d/optout.

--
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 post to this group, send email to ansible...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Romeo
Reply all
Reply to author
Forward
0 new messages