How can I roll out files to multiple remote /home/* directories?

I have this playbook to roll out “dot” config files:

— - hosts: linuxboxes tasks: - name: Update .* config files in $HOME copy: src: “{{ item }}” dest: /home/user1/ owner: user1 group: user1 with_fileglob: - /home/master/System_Configs/Bash-Profiles/Linux/Ubuntu/User/.*

This playbook is working OK for this one user “user1” and it does what it says: It takes all the “dot” files such as “.bashrc”, “.vimrc” and so on from that master directory and updates them with the new defaults I have defined. So all the “dot” files are the same across all hosts in the “linuxboxes” group for this one user. No problem there.

But what if I have multiple existing users? Copying & pasting that “copy:” block and redoing it for every user seems redundant and let’s be honest: it’s bad style.

How could I get ansible to loop over every /home/* directory and copy my defaults to each existing user’s home?

I imagine I’d have to work with 2 x different “{{ item }}” loops but I am not really sure how to do it …?

I also have this little playbook below that fetches a list of remote home directories that exist (see below). How could I feed the results below (the list of remote home directories) as “dest” argument into the playbook above?

Hello,
Have you able to resolved your issue?

Any idea or happy to share.

Thanks,
Erwin