propagate nested loop substitution for added data restructuring task using set_facts module
#12
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
When one needs to traverse to separate data structures using a loop, the options are either:
Because Ansible does not have robust or intuitive support for nested loops, I decided in a given case within the
roles/init-server/ssh-users.ymlfile, to rewrite the code thus:Other places (such as
roles/init-server/spawn.yml) where a similar conundrum may arise, and thus that may benefit from a similar solution, are those that involve grabbing public SSH keys from the active system user running ansible (even if through sudo or change of user), and distributing those public keys to the appropriate users per definitions ingroup_vars/*androles/init-server/{vars,defaults}/users@linux.yml. The above image should be a reference solution in those similar scenarios.Note that manually defined playbook variables
local_facts.user_dirandlocal_facts.user_idwill also tend to be of use in these similar cases.