Re: [ansible-project] Re: Accessing contents of a fact in a loop

2021-12-07 Thread lift...@gmail.com
So after I sent that, i did some more playing around, and I think I have what I need for now. I'm setting multiple facts in 1 fact as follows: - name: Set user_show fact set_fact: users: - "{{ user_show.results[0].json.result.result.uid[0] }}" - "{{

Re: [ansible-project] Re: Accessing contents of a fact in a loop

2021-12-07 Thread Todd Lewis
> When I print out user_show… Can you please show your step where you print out `user_show` (presumably a debug step), and all relevant parts of its output. "Relevant parts" would include any `[` or `{` characters, i.e. anything showing the context of "krbpasswordexpiration" in the registered

Re: [ansible-project] Re: Accessing contents of a fact in a loop

2021-12-07 Thread lift...@gmail.com
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: user_find.json.result.result returns: "result": [ {

Re: [ansible-project] Re: Accessing contents of a fact in a loop

2021-12-03 Thread Chris Smart
On Sat, 4 Dec 2021 at 09:08, Todd Lewis wrote: > I don't see where you're setting uid, the debug step, or its output. All I > see is that > >loop: > - "{{ uid }}" > > is only producing one invocation of the task with the desired values all > glommed into one string. > Please show your

Re: [ansible-project] Re: Accessing contents of a fact in a loop

2021-12-03 Thread Todd Lewis
You left out the rest of your set_fact step. Please include the whole step. Thanks. On Friday, December 3, 2021 at 7:03:07 PM UTC-5 lift...@gmail.com wrote: > I set it as a fact using your suggestion: > user_find.json.result.result|map(attribute='uid')|flatten > > Harry > > On Fri, Dec 3, 2021,

Re: [ansible-project] Re: Accessing contents of a fact in a loop

2021-12-03 Thread harry devine
I set it as a fact using your suggestion: user_find.json.result.result|map(attribute='uid')|flatten Harry On Fri, Dec 3, 2021, 5:08 PM Todd Lewis wrote: > I don't see where you're setting uid, the debug step, or its output. All I > see is that > >loop: > - "{{ uid }}" > > is only

[ansible-project] Re: Accessing contents of a fact in a loop

2021-12-03 Thread Todd Lewis
I don't see where you're setting uid, the debug step, or its output. All I see is that loop: - "{{ uid }}" is only producing one invocation of the task with the desired values all glommed into one string. Please show your input code and resulting output. I suspect you're somehow

[ansible-project] Re: Accessing contents of a fact in a loop

2021-12-03 Thread lift...@gmail.com
That works, but when I try to then call the IPA user_show API, which takes the UID as a parameter, the entire list generated is sent in. - name: Run user_show from IDM API using previously stored session cookie uri: url: "https://{{idmfqdn}}/ipa/session/json; method: POST

[ansible-project] Re: Accessing contents of a fact in a loop

2021-12-03 Thread Todd Lewis
I really want to love Ansible, but the fact that such a simple data manipulation completely eludes the newbie doesn't help. Worse, that I've done this (or equivalent) dozens of times and it still takes me as long as it does to come up with a working demo ... [sigh]. Anyway, here's a working

[ansible-project] Re: Accessing contents of a fact in a loop

2021-12-03 Thread lift...@gmail.com
So I'm still trying to get this to work. I'm thinking that the fact is one large item, so I need to know how I can loop through those items. I'm trying to get the UID of each user. What the user_find IPA API call returns is .json.result.result, and the users are added to the fact in the

[ansible-project] Re: Accessing contents of a fact in a loop

2021-11-30 Thread lift...@gmail.com
I had done that previously and knew it was getting the right data, but I put the debug back in and the redacted output is below. There are over 1600 users, so I am only showing the start of the data in a redacted form. The debug print is printing "{{ user_find.json.result.result }}": TASK

[ansible-project] Re: Accessing contents of a fact in a loop

2021-11-29 Thread Todd Lewis
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