Ansible get_url fails to download a protected by basic auth -


i'm trying download protected file using http remote server get_url module username password not seem passed in request , task therefore fails.

i'm using ansible 1.9.2

here get_url definition i'm using:

- name: downloading artifact   get_url:       url: "http://myserver/somefile.tar.gz"      dest: "/home/jdoe/somefile.tar.gz"     url_username: "jdoe"     url_password: "mysecret"     mode: 0600 

here error get:

failed: [myserver] => {"dest": "/home/jdoe/somefile.tar.gz", "failed": true, "response": "http error 403: forbidden", "state": "absent",  "status_code": 403, "url": "http://myserver/somefile.tar.gz"} msg: request failed fatal: hosts have failed -- aborting 

now, tried download file using curl , works.

any appreciated i've struggling 2 days.

you can use uri module:

---                                               - hosts: hostname                                    tasks:                                            - name: "download file"                            uri:                                               url: "http://somedomain.com/file.json"           method:                                      user: "{{ somedomain.user }}"                   password: "{{ somedomain.password }}"           force_basic_auth: yes                           dest: /tmp/somedomain.file.json                  return_content: yes                        

if doesn't work, have httplib2 library version.


Comments

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

mercurial graft feature, can it copy? -