- Make sure ansible is installed
ansible.cfg
lets ansible know the inventory file to use. The default location of inventory file is/etc/ansible/hosts
.- We can also let ansible know which inventory file to use by defining it inside
ansible.cfg
, this way we do not have to use the-i
flag all the time. inventory.yml
contains the group of hosts.- Directory
playbooks
contains all playbooks.main.yml
imports other playbook.
Dry run any playbook with the --check
flag for example ansible-playbook playbooks/secure.yml --check
ansible-inventory --list
ansible -m ping all -i inventory.yml
or ansible -m ping all
ansible -m ping webservers -i inventory.yml
or ansible -m ping webservers
Run this as the first playbook as this is meant to secure the Raspberry pi by setting up an SSH based authentication and disable the password based authentication. Once this run successfully you do not need to run this again, unless you are adding another host in inventory.
ansible-playbook playbooks/secure/run.yml --ask-pass
--ask-pass
will ask for a password, enter the password of a system you are SSHing into.
Create a user that will do deployment
playbooks/dependencies/user/deploy.yml
To update all hosts
ansible-playbook playbooks/update/run.yml
To shutdown all hosts
ansible-playbook playbooks/shutdown/run.yml
- Find out how to manage dependencies
ansible-galaxy
- Secureing Raspberry pi
- Add SSH key to the PI
- Disable password based login
- Use template
- For setting hostnames
- Webserver
- Database
- Redis
- For setting hostnames
- Implement collections
- Shutdown specific host
- Deployment
- Deploy user
- Dependencies