This repository Contains Ansible playbooks for CentOS, Debian and Ubuntu. Uses Docker, Docker Compose, Ansible Vault and secure setup for environment variables. Provides a wide range of Docker Compose scripts too, integrated with Ansible Vault for secure variables.
Make sure public key in the local machine is registered to the authorized_keys file in your server(s), so Ansible can do ssh to your servers.
This Ansible project layout assumes these conditions:
- The Ansible variables file is located at ~/ansible/vars.yml in the local machine (as stated in docker.yml files).
- Default vault password is the_fault_is_our_stars and vault file is assume t be stored at ~/.vault_pass.txt, change it with your own vault password with Ansible rekey command or simply decrypt the files and encrypt with new vault password.
- Environment variables file to be set in remote machines is located at ./vars/vaults/envvars.
- Environment variables file for Docker compose is located at ./vars/vaults/.env.
- Docker compose files located at ./vars/composes directory.
- You can add your own docker compose files at ./vars/composes directory and add them to Run compose file(s) task's vars.
To change inventory, please edit os-name/inventory/host.yml to represent your servers inventory. Please refer to this documentation from Ansible for the syntax and rules.
Let's say we want to run Ansible for Ubuntu 20.04 server:
cd ubuntu20.04
ansible-playbook -i inventory \
--vault-password-file ~/.vault_pass.txt \
docker.yml
You can run any other containers listed in the compose folder in this repository. These files are coming from this gist.