So I'm close.  I am able to get the items from the returned list via the 
IPA API:

  - 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

I can print them out and get the info I need:

  - name: Print output
    debug:
      msg: "{{ item.uid[0] }}:  {{ item.gidnumber[0] }}:  {{ 
item.homedirectory[0] }}"
    with_items: "{{ user_find.json.result.result| }}"

However, in my other thread about removing items from the list, I'm trying 
the suggestion as follows:

  - name: Print output
    debug:
      msg: "{{ item.uid[0] }}:  {{ item.gidnumber[0] }}:  {{ 
item.homedirectory[0] }}"
    loop: "{{ user_find.json.result.result|difference(deny) }}"
    vars:
    deny: ["/home/admin","/home/test"]

This gives me the following validation error:

ERROR! conflicting action statements: debug, deny

I won't be using debug in the final version of the playbook, so since I 
know that I can get the info I need, should I  just move onto that?  Or is 
there a way to get debug and deny to coexist to I can be SURE I'm getting 
what I need first?

Thanks,
Harry
On Tuesday, October 5, 2021 at 6:03:38 PM UTC-4 flowerysong wrote:

> While the use of json_query obscures the actual structure that you're 
> dealing with (and you haven't provided an example), this looks an awful lot 
> like you're taking something where you already have all of the information 
> you want in a list, and turning it into three lists. Is there a reason you 
> can't just use user_find.json.result.result directly?
>
> On Tuesday, October 5, 2021 at 2:28:09 PM UTC-4 [email protected] wrote:
>
>> I'm querying our FreeIPA server for user information.  What I need is 
>> there UID, GID, and Home directory.  I can get those individually, but how 
>> can I set a fact that combines all of these items?  Here's the 3 separate 
>> facts, I just can't figure out how to have an array of them:
>>
>>   - name: Set User facts
>>     set_fact:
>>       user_uid: "{{ user_find.json.result | json_query('result[].uid[]') 
>> }}"
>>       user_gid: "{{ user_find.json.result | 
>> json_query('result[].gidnumber[]') }}"
>>       user_list: "{{ user_find.json.result | 
>> json_query('result[].homedirectory[]') }}"
>>
>> Any ideas?
>> 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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/00264fe9-de8b-41ef-94f9-4dbbfa3b8f61n%40googlegroups.com.

Reply via email to