Ansible Playbooks
Collection of Ansible playbooks and roles.
Roles
- docker - Install Docker for Ubuntu
- docker-network - Define internal Docker network
- postgres - Deploy PostgreSQL database container
- openldap - Deploy OpenLDAP Docker container
- odoo - Deploy Odoo container
- odoo-scripts - Install Odoo scripts
- debug - Debug Ansible variables
- modsecurity - Download and configure ModSecurity with OWASP CRS
- nginx - Deploy Nginx proxy with Let's Encrypt certificates and ModSecurity
- clean - Cleanup Ansible roles
- mysql - Deploy MySQL database container
- bookstack - Deploy BookStack Docker container
- nextcloud - Deploy Nextcloud container
- colabora-code - Deploy Nextcloud container
- moodle - Deploy Moodle container
- iam - Configures users and groups
- restic-client - Configure Restic client backup jobs
- restic-server - Deploy Restic server container
- elasticsearch - Deploy ElasticSearch Docker cluster
- kibana - Deploy Kibana Docker container
- logstash - Deploy Logstash Docker container
- metricbeat - Deploy Metricbeat Docker container
- cadvisor - Deploy cAdvisor Docker container
- node-exporter - Deploy node-exporter Docker container
- prometheus - Deploy Prometheus Docker container
- grafana - Deploy Grafana Docker container
- keycloak - Deploy Keycloak Docker container
- update - Install system and package updates
- bigbluebutton - Install BigBlueButton with https and greenlight.
- package - Install and pin packages.
Usage
Clone this repository.
git clone https://github.com/Mint-System/Ansible-Playbooks.git && cd Ansible-Playbooks
Setup
Set a password to encry the Ansible vault.
export VAULTPASSWORD=PASSWORD
Create a password file.
echo "$VAULTPASSWORD" > .vault_pass
Make it executable.
chmod 600 .vault_pass
Install jmespath with pip.
pip3 install jmespath
Install dnspython with pip.
pip3 install dnspython
Create an inventory and configure a role.
Deployment
List inventory
ansible-inventory --list -y -i inventories/odoo
Test connection
ansible all -m ping -i inventories/odoo
Deploy multiple inventories
ansible-playbook -i inventories/setup -i inventories/odoo -i inventories/proxy odoo.yml
Deploy odoo stack
ansible-playbook -i inventories/odoo odoo.yml
Deploy role only
ansible-playbook -i inventories/odoo odoo.yml -t postgres
Deploy without dependencies
ansible-playbook -i inventories/odoo odoo.yml --skip-tags dependencies
Deploy role to specific host
ansible-playbook -i inventories/odoo odoo.yml -t docker -l host.example.com
Deploy role to specific group with non-default user
ansible-playbook -i inventories/odoo docker.yml -t docker -l europe -u username
Clean odoo stack
ansible-playbook -i inventories/odoo clean.yml -t odoo,odoo-volume,odoo-data-dir,postgres,postgres-volume
Clean role only
ansible-playbook -i inventories/odoo clean.yml -t docker-network
Install odoo-scripts locally
ansible-playbook localhost.yml
Docs
Quality
Lint the project using Ansible lint.
ansible-lint *.yml
Config
Whenever possible use env variables to configure the container.
Env Config
env:
POSTGRES_USER: "{{ postgres_user }}"
POSTGRES_PASSWORD: "{{ postgres_password }}"
POSTGRES_DB: "{{ postgres_db }}"
Data
To persist data use Docker volumes.
Volume Mount
Mount the folder without subfolder.
volumes:
- "{{ postgres_volume_name }}:/var/lib/postgresql/data"
For Ansible config files use file mounts.
Bind Mount
volumes:
- "{{ nginx_data_dir }}/:/etc/nginx/conf.d/:ro"
Guidelines
Every role folder must contain a README.md file.
Mark fixme comments with # FIXME: <your text>.
Naming
Template for role vars:
# Basics:
# Url to Docker repsitory
ROLENAME_image: URL
ROLENAME_hostname: SHORTNAME + COUNTER
ROLENAME_port:
ROLENAME_volume_name: SHORTNAME_data + COUNTER
ROLENAME_data_dir: /usr/share/SHORTNAME + COUNTER
# Database connection:
ROLENAME_db_type: mysql
ROLENAME_db_user:
ROLENAME_db_password: "{{ vault_ROLENAME_db_password }}"
ROLENAME_db_hostname:
ROLENAME_db_name:
# Credentials user:
ROLENAME_user:
ROLENAME_password: "{{ vault_ROLENAME_password }}"
# Credentials admin:
ROLENAME_admin_user:
ROLENAME_admin_password: "{{ vault_ROLENAME_admin_password }}"
# Named database connection:
ROLENAME_postgres_hostname:
ROLENAME_postgres_user:
ROLENAME_postgres_password: "{{ vault_ROLENAME_postgres_password }}"