Discussion:
[ansible-project] URI Module fails POST but CURL succeds as shell
s***@oration.com
2015-07-06 03:53:07 UTC
Permalink
I am getting a connection refused socket error :111 when using get_uri
module for POST of a zip file to a url . If i use curl command on shell the
task runs without error. How can i fix this issue?
--
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-project+***@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/88f8e809-9ce6-4e7a-ad43-39fc3f78abbf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Romeo Theriault
2015-07-06 14:06:47 UTC
Permalink
What does it show you when you run it in verbose mode?
Post by s***@oration.com
I am getting a connection refused socket error :111 when using get_uri
module for POST of a zip file to a url . If i use curl command on shell the
task runs without error. How can i fix this issue?
--
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
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/88f8e809-9ce6-4e7a-ad43-39fc3f78abbf%40googlegroups.com
<https://groups.google.com/d/msgid/ansible-project/88f8e809-9ce6-4e7a-ad43-39fc3f78abbf%40googlegroups.com?utm_medium=email&utm_source=footer>
.
For more options, visit https://groups.google.com/d/optout.
--
Romeo
--
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-project+***@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/CACUx58PqpEGGyM7E%2Bnk5aYim3tABQkqzsqOeFd%3DBxE7y_Wfi9A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
s***@oration.com
2015-07-09 01:37:43 UTC
Permalink
Hello, this is the error I get , when i run it in verbose mode.
TASK: [Curl to post to oabc] *******************************************
<10.1.3.163> ESTABLISH CONNECTION FOR USER: ubuntu
<10.1.3.163> REMOTE_MODULE uri
url='http://localhost/api/v1.0/abcd?abcdZipFile=abcd_v3.0_20150701.ZIP'
<10.1.3.163> EXEC ssh -C -tt -vvv -o ControlMaster=auto -o
ControlPersist=60s -o
ControlPath="/home/vagrant/.ansible/cp/ansible-ssh-%h-%p-%r" -o
IdentityFile="/home/vagrant/ahafasfhsalf_Dev.pem" -o
KbdInteractiveAuthentication=no -o
PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey
-o PasswordAuthentication=no -o User=ubuntu -o ConnectTimeout=120
10.1.3.163 /bin/bash -c 'mkdir -p
$HOME/.ansible/tmp/ansible-tmp-1436405328.75-170552693510188 && chmod a+rx
$HOME/.ansible/tmp/ansible-tmp-1436405328.75-170552693510188 && echo
$HOME/.ansible/tmp/ansible-tmp-1436405328.75-170552693510188'
<10.1.3.163> PUT /tmp/tmpGByUla TO
/home/ubuntu/.ansible/tmp/ansible-tmp-1436405328.75-170552693510188/uri
<10.1.3.163> EXEC ssh -C -tt -vvv -o ControlMaster=auto -o
ControlPersist=60s -o
ControlPath="/home/vagrant/.ansible/cp/ansible-ssh-%h-%p-%r" -o
IdentityFile="/home/vagrant/ahafasfhsalf_Dev.pem" -o
KbdInteractiveAuthentication=no -o
PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey
-o PasswordAuthentication=no -o User=ubuntu -o ConnectTimeout=120
10.1.3.163 /bin/bash -c 'sudo -k && sudo -H -S -p "[sudo via ansible,
key=szyrygobamhtrmdhebttkjwsmjgkyuhc] password: " -u root /bin/bash -c
'"'"'echo BECOME-SUCCESS-szyrygobamhtrmdhebttkjwsmjgkyuhc; LANG=C
LC_CTYPE=C /usr/bin/python
/home/ubuntu/.ansible/tmp/ansible-tmp-1436405328.75-170552693510188/uri; rm
-rf /home/ubuntu/.ansible/tmp/ansible-tmp-1436405328.75-170552693510188/
/dev/null 2>&1'"'"''
failed: [10.1.3.163] => (item=abcd_v3.0_Monthly_Master_20150701.ZIP) =>
{"failed": true, "item": "abcd_v3.0__20150701.ZIP"}
msg: Socket error: [Errno 111] Connection refused to
http://localhost/api/v1.0/abcd?abcdZipFile=abcd_v3.0__20150701.ZIP
...ignoring
--
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-project+***@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/18e4ec34-7503-4d84-99b5-18aca5412c10%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Brian Coca
2015-07-09 02:35:32 UTC
Permalink
where is the api running? can you show the curl command that succeeds?
where do you run it from?
--
Brian Coca
--
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-project+***@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/CAJ5XC8knmdLygSCgnwysNrK5yGCg4THeeguWBnijTYAzh1bK9Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
s***@oration.com
2015-07-09 18:21:27 UTC
Permalink
The API is running on 10.1.3.163
Post by Brian Coca
where is the api running? can you show the curl command that succeeds?
where do you run it from?
--
Brian Coca
--
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-project+***@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/6c87bc04-c9b6-4883-a56e-90b432144b4d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
s***@oration.com
2015-07-09 18:21:00 UTC
Permalink
The playbook below works with CURL in SHELL but not URI
---
- hosts: 10.1.3.163
user: ubuntu
sudo: yes
vars_files:
- vars.yml
tasks:
- name: Run curl
shell: curl --request POST
'http://localhost:9004/api/v1.0/abcd?abcdZipFile=/home/abcd/upload/abcd.zip
Post by s***@oration.com
I am getting a connection refused socket error :111 when using get_uri
module for POST of a zip file to a url . If i use curl command on shell the
task runs without error. How can i fix this issue?
--
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-project+***@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/9547ee93-cf5d-444f-84ca-49db1fc8948a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Romeo Theriault
2015-07-09 18:59:44 UTC
Permalink
It looks like you're missing the port (9004) in the URI call. Which would
make sense because it's getting a "connection refused" socket level error.
Post by s***@oration.com
The playbook below works with CURL in SHELL but not URI
---
- hosts: 10.1.3.163
user: ubuntu
sudo: yes
- vars.yml
- name: Run curl
shell: curl --request POST '
http://localhost:9004/api/v1.0/abcd?abcdZipFile=/home/abcd/upload/abcd.zip
Post by s***@oration.com
I am getting a connection refused socket error :111 when using get_uri
module for POST of a zip file to a url . If i use curl command on shell the
task runs without error. How can i fix this issue?
--
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
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/9547ee93-cf5d-444f-84ca-49db1fc8948a%40googlegroups.com
<https://groups.google.com/d/msgid/ansible-project/9547ee93-cf5d-444f-84ca-49db1fc8948a%40googlegroups.com?utm_medium=email&utm_source=footer>
.
For more options, visit https://groups.google.com/d/optout.
--
Romeo
--
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-project+***@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/CACUx58OQ35fsRtPWyFLTmKWT3rzCH9YVY89-orYVvkViWq%3Dpbg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
s***@oration.com
2015-07-09 19:50:12 UTC
Permalink
This post might be inappropriate. Click to display it.
Romeo Theriault
2015-07-09 21:17:45 UTC
Permalink
Getting closer. 500 is an internal server error. Do you have access to the
server logs? Also, run the playbook with --verbose and set
return_content=yes on the task.

I'd also wrap the url in doublequotes. I'm guess the url string is getting
messed up somehow.
Post by s***@oration.com
I added the port and tested again. here is the error I get.
####################
failed: [10.1.3.163] => (item=abcd_v3.0_Monthly_Master_20150701.ZIP) =>
"abcd_v3.0_Monthly_Master_20150701.ZIP", "redirected": false, "status": 500}
msg: Status code was not [200]
...ignoring
#################
This is the task in the playbook
- name: Curl to post to xxxx
url: http://localhost:9004/api/v1.0/abcd?abcdZipFile={{ item }}
method: POST
status_code: 200
with_items: abcdUPLOAD.stdout_lines
register: status
ignore_errors: True
- debug: var=status
Post by s***@oration.com
I am getting a connection refused socket error :111 when using get_uri
module for POST of a zip file to a url . If i use curl command on shell the
task runs without error. How can i fix this issue?
--
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
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/fd9c9e16-c8fe-4377-ac49-9e877063f509%40googlegroups.com
<https://groups.google.com/d/msgid/ansible-project/fd9c9e16-c8fe-4377-ac49-9e877063f509%40googlegroups.com?utm_medium=email&utm_source=footer>
.
For more options, visit https://groups.google.com/d/optout.
--
Romeo
--
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-project+***@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/CACUx58MfpKFGDV%3DZaOjbOQAZq-YuzUjdeK196XNV6-AFWRuPsg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Toshio Kuratomi
2015-07-09 22:15:15 UTC
Permalink
Post by s***@oration.com
I added the port and tested again. here is the error I get.
####################
failed: [10.1.3.163] => (item=abcd_v3.0_Monthly_Master_20150701.ZIP) =>
"abcd_v3.0_Monthly_Master_20150701.ZIP", "redirected": false, "status": 500}
msg: Status code was not [200]
...ignoring
#################
This is the task in the playbook
- name: Curl to post to xxxx
url: http://localhost:9004/api/v1.0/abcd?abcdZipFile={{ item }}
method: POST
status_code: 200
with_items: abcdUPLOAD.stdout_lines
register: status
ignore_errors: True
- debug: var=status
Status code 500 is an internal server error which means the application
you're talking had a problem. Might check the logs for the application to
see if it reported why it couldn't handle the request.

I also note that the filename that the uri module is trying to POST is
different from the filename in your curl. That might be a clue as well.

-Toshio
--
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-project+***@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/CAG9juEqF9e9JKY%2B8-FKXqM%2BWoxdJQcuv0z%2Br-EZDJW2rbFc2Gg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Loading...