We're evaluating Ansible and learning how to use it. I'm trying to using 
Ansible to call the Ansible api's. I have an issue with the uri module in 
trying to reference the response from the authtoken API to use in 
subsequent requests. Per the docs, the return_content option is supposed to 
put the json response in the dictionary with the name json. I'm ASSUMING 
the dictionary is the repository for variables. So, when these tasks run, 
the second one throws an error saying that the json varaible does not 
exist. 

Can someone tell me how I can reference the response as a variable?


The tasks I wrote is:

  - uri: 
      url:  https://10.0.0.4/api/v1/authtoken/
      method: POST
      HEADER_Content-Type: application/json  
      body: '{ "username" : "myusername", "password" : "mypassword" }'
      validate_certs: no
      return_content: yes
      register: authentication
  
  - uri: 
      url:  https://10.0.0.4/api/v1/users/
      method: GET
      HEADER_Authorization: TOKEN {{ json.token }} 
      validate_certs: no
      return_content: yes

-- 
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/15ce9f57-e79c-44bc-ad1f-0c6aa958309d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to