OK, so that works, but I'm still having issues with referencing. So I'm using user_find from the IPA API using the uri module. I get the user account info correctly as follows:
"result": [
{
"dn": "uid=harry.devine,cn=users,cn=accounts,dc=example,dc=com",
"gidnumber": [
"10000"
uid: "{{ user_find.json.result.result|map(attribute='uid')|flatten }}"
then use that fact into the url module using the IPA API user_show. When I print out user_show, I get the following (I left out most of the user information as it's redundant):
"krbpasswordexpiration": [
{
"__datetime__": "20220220212310Z"
}
So when I print out the password expiration, I can reference it using user_show.results[0].json.result.result.krbpasswordexpiration[0]['__datetime__']. But when I try to set a fact with that information, I get an error that says that krbpasswordexpiration doesn't exist. Here's that set_fact:
- name: Set fact for password expirations
set_fact:
pwdexpires: "{{ user_show.results[0].json.result.result|map(attribute='krbpasswordexpiration') | flatten }}"
What I'm hoping to get to is:
1) Find all users and set the uid fact
2) Loop through those uid values and call user_show so I can retrieve each user's password expiration
3) Determine if their password has expired more than 180 days
4) Create a list of users to disable
5) Loop through that list and disable each user
6) Email each user to inform them of the disable
So I have 1 and 2 working, but transitioning to 3 using both facts (uid and pwdexpires) is what's giving me trouble. Any thoughts/ideas on how to accomplish the retrieval of the password expiration and have it in a fact? Or, maybe the better question is: can I have a fact with more than one value in it: 1 for uid and 1 for password expiration? I already know the uid via the result of user_show, so I should be able to pull out both values, but how?
Thanks, and sorry for the long-winded explanation. Just trying to be as thorough and complete with you all.
Harry