URI Module instead of curl

218 views
Skip to first unread message

Chip Selden

unread,
Mar 4, 2015, 2:50:20 PM3/4/15
to ansible...@googlegroups.com
Hey all,

Trying to use the URI module instead of a curl command and I can't seem to get the usage right.

Here's the shell command:
curl -X POST --data "action=login&username={{api_user}}&password={{api_pass}}" {{api_URL}} -k

Here's what I have for the module args but I'm not sure how to pass in the --data section
- name: Start new API session
  uri:
    method=POST
    url={{api_URL}}
    returncontent=yes
  register: session_id_raw
  when: session_id is not defined

I'm not sure where to pass in the other flags and arguments. Any help would be much appreciated.

Thanks,
Chip

Matt Martz

unread,
Mar 4, 2015, 7:01:29 PM3/4/15
to ansible...@googlegroups.com
Here is an example from the URI module docs:

- uri:  url=https://your.form.based.auth.examle.com/index.php method=POST body="name=your_username&password=your_password&enter=Sign%20in" status_code=302 HEADER_Content-Type="application/x-www-form-urlencoded" register: login 

You should be able to manipulate that with your parameters to get what you need.
--
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/0c363209-6b6b-4a1b-9ae1-25bab4f49ba4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--
Matt Martz
@sivel
sivel.net

Reply all
Reply to author
Forward
0 new messages