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?
---
- hosts: linuxboxes tasks: - name: Get list remote /home/* directories
shell: ls /home | grep -v "lost+found" register: userhomes changed_when:
false - name: Print list of remote /home/* directories debug: msg={{
userhomes.stdout_lines }}
Thanks in advance for your suggestions :)
--
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 view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/c9e2ceaf-4976-4c8a-b13f-93f7e4ae235f%40googlegroups.com.