MD> However, what's happening is "item" is the only thing that decides
MD> what you are looping over.
Right; the thing that we wanted to do here, if I were expressing it in
Python-like pseudocode, would be something like:
for user in allusers:
if user in itertools.chain(produsers, stgusers):
do stuff
That is, our logic is to iterate over the list of all users, and then see
if each of them is in the flattened list of authorized users, do stuff if
they are, and skip them if they aren't. But to do that, we need to get our
hands on the flattened list of authorized users, and we can't do that with
with_flattened, because we're already in the middle of a with_items across
the list of all users.
After thinking about it some more, though, we think that our approach here
is wrong: Rather than iterating over the list of all users, and seeing if
they're in one of the lists of authorized users, we should instead iterate
over the flattened list of authorized users (which we can get just fine
via with_flattened), and look up the information about each user that way.
We didn't think of this at first because our list of all users is
currently a list of dicts, but if it were a dict, that would work fine.
(This is a slightly simplified example -- in our real use case, allusers
isn't just a list of usernames, it's a list of dicts about each user. It
should really be a dict of dicts instead, and then everything else would
work perfectly.)
https://groups.google.com/d/msg/ansible-project/W-o_hXj-6IA/hzJFs3GRcd4J
has an example of this -- that's actually the post that inspired us to do
it the way we're doing it now, but because our users were a list rather
than a dict, that example didn't work out of the box, and we came up with
this other weird thing that seemed to work.
-Josh ([email protected])
This email is intended for the person(s) to whom it is addressed and may
contain information that is PRIVILEGED or CONFIDENTIAL. Any unauthorized use,
distribution, copying, or disclosure by any person other than the addressee(s)
is strictly prohibited. If you have received this email in error, please notify
the sender immediately by return email and delete the message and any
attachments from your system.
--
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 post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/21539.7589.67393.838210%40gargle.gargle.HOWL.
For more options, visit https://groups.google.com/d/optout.