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