Re: [ansible-project] Issue with selectattr

2024-02-26 Thread lift...@gmail.com
I think I got it. I set the fact like so: - name: Find users who's password will expire in the next {{ warning_days }} days ansible.builtin.set_fact: pwd_expire_soon: "{{ user_show.results | json_query('[*].json.result.result.{uid: uid[0], pwdchg:

Re: [ansible-project] Issue with selectattr

2024-02-26 Thread Todd Lewis
Assuming what you posted is the result of:   - name: Show user info     debug: msg: "{{ user_show.results | json_query('[*].json.result.result.{uid: uid[0], pwdchg: krblastpwdchange[0].__datetime__}') }}" Then throw this onto the end: | selectattr("pwdchg", "!=", None) You could

Re: [ansible-project] Issue with selectattr

2024-02-26 Thread lift...@gmail.com
I totally understand where you're coming from. You guys have always been great and extremely helpful, and I appreciate that. I have adjusted the playbook to look at the first 5 users, and the anonymized output is below. Thanks, Harry TASK [Show user info]

Re: [ansible-project] Issue with selectattr

2024-02-26 Thread Todd Lewis
Normally I would change krblastpwdchange[0].__datetime__ to krblastpwdchange[0].__datetime__ | default('0') but your expression is part of json_query(). Perhaps there's an equivalent of Jinja's default() in json_query(); I just don't know. Without standing up an IPA instance and

Re: [ansible-project] Issue with selectattr

2024-02-26 Thread lift...@gmail.com
I'm including the playbook below. I'm still unable to find a way to ignore any user that does not have the krblastpwdchange property set. When I run the playbook, I still get the following error: TASK [Find users who's password will expire in the next 10 days]

Re: [ansible-project] Issue with selectattr

2024-02-23 Thread lift...@gmail.com
So it looks like the VERY 1st user in our system has never logged in, so the krblaspwdchange property has never gotten set. Is there a way to ignore when that field doesn't exist or is null? Thanks, Harry On Friday, February 23, 2024 at 2:46:07 PM UTC-5 Todd Lewis wrote: > The original

Re: [ansible-project] Issue with selectattr

2024-02-23 Thread Todd Lewis
The original problem is you're comparing 'NoneType' and 'str'. So, for at least one of your principals there's no krblastpwdchange. You need to work on the subset of data relevant to the comparison. On 2/23/24 2:09 PM, lift...@gmail.com wrote: I'm not including the entire playbook, but the URI

Re: [ansible-project] Issue with selectattr

2024-02-23 Thread lift...@gmail.com
I'm not including the entire playbook, but the URI module call where user_show gets registered, then the debug statements: - name: Run user_show from IDM API using previously stored session cookie ansible.builtin.uri: url: "https://{{idmfqdn}}/ipa/session/json; method: POST

Re: [ansible-project] Issue with selectattr

2024-02-23 Thread Todd Lewis
Without showing us the expression you used in your debug's "msg:", this doesn't tell us anything. On 2/23/24 1:05 PM, lift...@gmail.com wrote: Looks OK to me: TASK [Show user info]

Re: [ansible-project] Issue with selectattr

2024-02-23 Thread lift...@gmail.com
Looks OK to me: TASK [Show user info] ** ok: [localhost] => { "msg": [ { "pwdchg":

Re: [ansible-project] Issue with selectattr

2024-02-23 Thread 'Rowe, Walter P. (Fed)' via Ansible Project
{{ user_show.results | json_query('[*].json.result.result.{uid: uid[0], pwdchg: krblastpwdchange[0].__datetime__}') }} I would display this info in a debug to see what the resulting data stream looks like. Maybe the selectattr('pwdchg') is in inaccurate reference to pwdchg? Walter -- Walter

Re: [ansible-project] Issue with selectattr

2024-02-23 Thread lift...@gmail.com
Just pull out those fields from the returned user information. I use that in 2 or 3 other playbooks so I know that it works. Thanks, Harry On Friday, February 23, 2024 at 11:53:04 AM UTC-5 Rowe, Walter P. (Fed) wrote: > pwd_expire_soon: "{{ user_show.results | >

Re: [ansible-project] Issue with selectattr

2024-02-23 Thread 'Rowe, Walter P. (Fed)' via Ansible Project
pwd_expire_soon: "{{ user_show.results | json_query('[*].json.result.result.{uid: uid[0], pwdchg: krblastpwdchange[0].__datetime__}') | selectattr('pwdchg', 'lessthan', 'expire_date') | list }}" What are you expecting this red portion to do? I don't think it is valid in json_query. Walter --

[ansible-project] Issue with selectattr

2024-02-23 Thread lift...@gmail.com
I am trying to determine when user's password's are going to expire in the next 10 days. After I traverse my FreeIPA users and store those users into a variable, I try to set a fact like so: - name: Find users who's password will expire in the next 10 days set_fact: pwd_expire_soon: