I'm getting started with Ansible.
I have few hosts in my /etc/ansible/hosts
.
This file and my playbooks are versioned with git.
Members of my team are versioned in git like
$cat users/john.json
{
login: 'john.johnson',
firstName: 'John',
lastName : 'Johnson',
sshPubKey: '....'
}
I want to grant access to some users to some machine like:
server1 [john, alice, bob]
server2 [john, alice]
server3 [john, bob]
server4 [john]
server5 [john, kevin]
server6 [john, albert, alice]
server7 [john, bob, kevin]
I'd also like to have the same approach for open ports like:
server1 [22, 80, 443]
server2 [22, 1234]
server3 [22, 1122]
server4 [22]
server5 [22, 1717]
server6 [22, 80, 443]
server7 [22]
I don't need help with writing the playbook's tasks (I know how to use the user/ufw module) but I can't find a way to cleanly centralise a per-host configuration with ansible.
The only solution I have for now is to have a user.yml
and port.yml
playbook, edit them every time I want to run them for a specific server and run the playbook with a --limit server1
. It doesn't feel clean and prevent me to have a clear snapshot on git of users' access and open ports for each server.
What would be the clean way to organise this in ansible ?