Using Ansible Playbooks
Running a playbook
First you need to have a playbook, you find them in the /scripts/ansible section of the docs or you can remote into the ansible master server and look at the playbooks in the /ansible/alto directory.
Checking the Inventory
Read more here: Inventory. When running a playbook you must have an inventory file. This file is a list of the hosts (server) that you want to perform the playbook on. It will contain the information required to ssh into the hosts. There is a single inventory file already on the ansible master server, with the contents encrypted.
ansible-vault edit ./inventory
This command will let you edit the inventory file, pass through the inventory file and use the password from vaultwarden. Follow the format of the existing entries, when adding the new hosts. Then make sure to add the server to the groups it needs to be in.
Once you have the playbook you want to run.
While inside the folder of the playbook you want to run. Use the following command to execute the playbook. If you look at the 'main.yml' file, the 'hosts' section will tell you which group the playbook will be run on. Change /root/temp/temp.password to be the location of your saved password.
ansible-playbook main.yml -f 2 --inventory ./inventory --vault-password-file /root/temp/temp.password -v
You will see the output in the terminal, you can add more -vvv if you need more verbose output for figuring out an error.
Odd playbooks.
There is a couple of playbooks that do not use the main Inventory. The main inventory uses ssh keys to connect to the hosts.
The 'install ssh key' playbook needs its own inventory setup because it uses password authentication. Because as you guessed this is the playlist adding the ssh key to the server so that it can be used in the other inventory file for other playbooks later on. New devices should have this run on them.