ANSIBLE.URI(3)

NAME
uri - Interacts with webservices

DESCRIPTION

Interacts with HTTP and HTTPS web services and supports Digest, Basic and WSSE HTTP authentication mechanisms.

OPTIONS

HEADER_
    Any parameter starting with "HEADER_" is a sent with your request as a header. For example, HEADER_Content-Type="application/json" would send the header "Content-Type" along with your request with a value of "application/json".

body
    The body of the http request/response to the web service.

creates
    a filename, when it already exists, this step will not be run.

dest
    path of where to download the file to (if desired). If dest is a directory, the basename of the file on the remote server will be used.

follow_redirects
    Whether or not the URI module should follow all redirects. Choices: yes,no. (default: no)

force_basic_auth
    httplib2, the library used by the uri module only sends authentication information when a webservice responds to an initial request with a 401 status. Since some basic auth services do not properly send a 401, logins will fail. This option forces the sending of the Basic authentication header upon initial request. Choices: yes,no. (default: no)

method
    The HTTP method of the request or response. Choices: GET,POST,PUT,HEAD,DELETE,OPTIONS. (default: GET)

others
    all arguments accepted by the file module also work here

password
    password for the module to use for Digest, Basic or WSSE authentication.

removes
    a filename, when it does not exist, this step will not be run.

return_content
    Whether or not to return the body of the request as a "content" key in the dictionary result. If the reported Content-type is "application/json", then the JSON is additionally loaded into a key called json in the dictionary results. Choices: yes,no. (default: no)

status_code
    A valid, numeric, HTTP status code that signifies success of the request. (default: 200)

timeout
    The socket level timeout in seconds (default: 30)

url HTTP or HTTPS URL in the form (http|https)://host.domain[:port]/path(required)

user
    username for the module to use for Digest, Basic or WSSE authentication.."

EXAMPLES

Check that you can connect (GET) to a page and it returns a status 200
uri: url=http://www.awesome.com

Check that a page returns a status 200 and fail if the word AWESOME is not in the page contents.
action: uri url=http://www.awesome.com return_content=yes
register: webpage
action: fail
when_string: '"AWESOME" not in "${webpage.content}"'

Create a JIRA issue.
action: >
        uri url=https://your.jira.server.com/rest/api/2/issue/
        method=POST user=your_username password=your_pass
        body='$FILE(issue.json)' force_basic_auth=yes
        status_code=201 HEADER_Content-Type="application/json"

Login to a form based webpage, then use the cookie that got returned to access the app in later tasks.
action: >
        uri url=https://your.form.based.auth.app.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
action: uri url=https://your.form.based.auth.app.com/dashboard.php method=GET return_content=yes HEADER_Cookie="${login.set_cookie}"
None

AUTHOR
Romeo Theriault

SEE ALSO
ansible(1), http://ansible.github.com/modules.html#uri