Before the step that's failing, insert a debug step with the msg: "{{ 
user_find.json.result.result }}" (really? "result.result"? maybe...) so you 
(and we) can be certain what your items actually look like. Otherwise, 
we're just guessing.


On Monday, November 29, 2021 at 3:05:37 PM UTC-5 lift...@gmail.com wrote:

> I am traversing our IPA server to get find all users, then I want to loop 
> through all of them to get their password expiration date.  I use the IPA 
> API via the uri module and register the variable, but no matter what I try 
> to access the uid of each found user, I get the following error:
>
> TASK [Run user_show from IDM API using previously stored session cookie] 
> **********************************************************
> fatal: [localhost]: FAILED! => {"msg": "template error while templating 
> string: expected name or number. String: {\"method\": 
> \"user_show\",\"params\": [[ \"{{ item[0].['uid'] }}\"],{\"all\": 
> true,\"version\": \"{{ api_vers }}\"}]}"}
>
> Here's the section of my playbook that seems to be giving me issues:
>
>   - name: Run user_find from IDM API using previously stored session cookie
>     uri:
>       url: "https://{{idmfqdn}}/ipa/session/json";
>       method: POST
>       headers:
>         Cookie: "{{ login.set_cookie }}"
>         Referer: "https://{{idmfqdn}}/ipa";
>         Content-Type: "application/json"
>         Accept: "application/json"
>       body_format: json
>       body: "{\"method\": \"user_find/1\",\"params\": [[],{\"version\": 
> \"{{ api_vers }}\"}]}"
>     register: user_find
>
>   - name: Run user_show from IDM API using previously stored session cookie
>     uri:
>       url: "https://{{idmfqdn}}/ipa/session/json";
>       method: POST
>       headers:
>         Cookie: "{{ login.set_cookie }}"
>         Referer: "https://{{idmfqdn}}/ipa";
>         Content-Type: "application/json"
>         Accept: "application/json"
>       body_format: json
>       body: "{\"method\": \"user_show\",\"params\": [[ \"{{ 
> item[0].['uid'] }}\"],{\"all\": true,\"version\": \"{{ api_vers }}\"}]}"
>     register: user_show
>     loop:
>     - "{{ user_find.json.result.result }}"
>
> Thanks,
> Harry
>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/7485a171-3a17-48b7-aeb6-da59d719d08en%40googlegroups.com.

Reply via email to