user66
(Александр Костырев)
March 19, 2015, 8:00pm
1
yet another question about loops
I want to be able to merge users across servers.
For example,
I want user1 to be on all of my hosts
and I want user_special_at_office to be only at my office’s servers
So I made inventory file, where I specified all of the groups.
I made group_vars for all and for office
As I’ve read I can merge only dictionaries.
file group_vars/all
There are various ways you could go about doing this. Here’s one of them.
users.yml
`
user66
(Александр Костырев)
March 26, 2015, 2:14pm
3
Thanks, Dan!
I’ve managed to do what I wanted with you help.
I ended up with:
setting hash_behaviour = merge in ansible.cfg
group_vars/all
`
users:
user1:
comment: “user1”
state: “present”
groups:
“wheel”
“dvp”
authorized:
“ssh-rsa 111”
“ssh-rsa 222”
user2:
comment: “user2”
state: ‘absent’
groups:
“wheel”
“dvp”
authorized:
“ssh-rsa 333”
user3:
comment: “user3”
state: ‘absent’
groups:
“wheel”
“dvp”
authorized:
“ssh-rsa 123”
user4:
comment: “user4”
state: ‘absent’
groups:
“dvp”
authorized:
“ssh-rsa 555”
`
group_vars/office
`