Hi Glenn, could you please open an issue on Github so we can keep track of
this?

Thanks!

James Cammarata
Director, Ansible Core Engineering
github: jimi-c

On Fri, Jan 15, 2016 at 8:26 AM, Glenn Barnard <[email protected]>
wrote:

> The underlying problem is this line in the include playbook:
>
>      body: '{ "username" : "{{ username }}", "password" : "{{ password }}"
> }'
>
> If I hardcode the username and password it works. So, this looks like an
> issue with uri, or I've not formatted this correctly.
>
> Suggestions anyone?
>
> On Monday, January 11, 2016 at 3:32:28 PM UTC-5, Glenn Barnard wrote:
>
>> Am using a current copy of Ansible and am in learning stage by writing
>> playbooks that call Ansible's API's via the uri module. Am getting an error
>> from the included yml that is trying to authenticate the user. Note that
>> it's working fine when I put the task into the main yml. The error is a
>> stack trace (below) followed with
>>
>>    TypeError: unhashable type
>>
>> Here's the main yml:
>>
>> ---
>> - name: Connect to Ansible API
>>   hosts: localhost
>>   connection: local
>>   gather_facts: no
>>   tasks:
>>   - include: authenticate.yml
>>       url="10.0.0.4"
>>       username="<username>"
>>       password="<password"
>>
>>   - debug: msg='{{ authentication.json }}'
>>
>>   - uri:
>>       url:  https://10.0.0.4/api/v1/users/
>>       method: GET
>>       HEADER_Authorization: TOKEN {{ authentication.json.token }}
>>       validate_certs: no
>>       return_content: yes
>>
>>
>> Here's the included yml:
>>
>> ---
>>
>>   - debug: msg="Connecting to Ansible host with {{ username }}/{{
>> password }}"
>>
>>   - name: Connect to ansible with creds provided
>>     uri:
>>       url: https://{{ url }}/api/v1/authtoken/
>>       method: POST
>>       HEADER_Content-Type: application/json
>>       body: '{ "username" : "{{ username }}", "password" : "{{ password
>> }}" }'
>>       validate_certs: no
>>       return_content: yes
>>     register: authentication
>>
>>
>> The stack trace is:
>>
>> TASK: [Connect to ansible with creds provided]
>> ********************************
>> failed: [localhost] => {"failed": true, "parsed": false}
>> Traceback (most recent call last):
>>   File
>> "/home/gbarnard/.ansible/tmp/ansible-tmp-1452538099.69-278641758230235/uri",
>> line 2081, in <module>
>>     main()
>>   File
>> "/home/gbarnard/.ansible/tmp/ansible-tmp-1452538099.69-278641758230235/uri",
>> line 416, in main
>>     resp, content, dest = uri(module, url, dest, user, password, body,
>> method, dict_headers, redirects, socket_timeut, validate_certs)
>>   File
>> "/home/gbarnard/.ansible/tmp/ansible-tmp-1452538099.69-278641758230235/uri",
>> line 312, in uri
>>     resp, content = h.request(url, method=method, body=body,
>> headers=headers)
>>   File "/usr/lib/python2.7/site-packages/httplib2/__init__.py", line
>> 1605, in request
>>     (response, content) = self._request(conn, authority, uri,
>> request_uri, method, body, headers, redirections, cacekey)
>>   File "/usr/lib/python2.7/site-packages/httplib2/__init__.py", line
>> 1353, in _request
>>     (response, content) = self._conn_request(conn, request_uri, method,
>> body, headers)
>>   File "/usr/lib/python2.7/site-packages/httplib2/__init__.py", line
>> 1290, in _conn_request
>>     conn.request(method, request_uri, body, headers)
>>   File "/usr/lib64/python2.7/httplib.py", line 979, in request
>>     self._send_request(method, url, body, headers)
>>   File "/usr/lib64/python2.7/httplib.py", line 1013, in _send_request
>>     self.endheaders(body)
>>   File "/usr/lib64/python2.7/httplib.py", line 975, in endheaders
>>     self._send_output(message_body)
>>   File "/usr/lib64/python2.7/httplib.py", line 839, in _send_output
>>     self.send(message_body)
>>   File "/usr/lib64/python2.7/httplib.py", line 811, in send
>>     self.sock.sendall(data)
>>   File "/usr/lib64/python2.7/ssl.py", line 723, in sendall
>>     v = self.send(data[count:])
>> TypeError: unhashable type
>>
>>
>> FATAL: all hosts have already failed -- aborting
>>
>> --
> 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 [email protected].
> To post to this group, send email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/23329c83-f554-400c-ad01-a86c612a0222%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/23329c83-f554-400c-ad01-a86c612a0222%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
> 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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAMFyvFh55xjscBGrU2xo9J26sZRwDMSM5cDBbitD-i70PnnPtQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to