This is my playbook to configure the basic stuff in my servers
- Configure ssh-key access to the servers
- Add ssh identyties to your ssh-agent. To do that:
- Execute
eval "$(ssh-agent -s)". It should be like:$ eval "$(ssh-agent -s)" > Agent pid XXXXX
- And then run
ssh-add ~/.ssh/i<key name>
- Execute
- Install ansible
- Create yout hosts inventory, or global one in
/etc/ansible/hostsor a local one. As an example:[all] 192.168.1.254 192.168.1.253 - Run the following to clarify if the server is working with ansible:
At this point, if all is working fine, you will se this:
ansible -i hosts all -u <user in the server> -m ping192.168.1.254 | SUCCESS => { "ansible_facts": { "discovered_interpreter_python": "/usr/bin/python3" }, "changed": false, "ping": "pong" }
ansible-playbook -i <inventory> -u <user> -K --extra-vars "ssh_port=<port>" main.yaml