This guide provides a full Ansible playbook to deploy Mautic with Docker Compose on Debian 10+, Ubuntu LTS, and RHEL 9+ compatible hosts.
mautic.example.com)- name: Deploy Mautic
hosts: mautic
become: true
vars:
app_root: /opt/mautic
app_port: 8080
mautic_db_password: "ChangeMe123!"
mautic_db_root_password: "RootChangeMe123!"
mautic_version: "latest"
tasks:
- name: Install Docker on Debian/Ubuntu
apt:
name:
- docker.io
- docker-compose-plugin
state: present
update_cache: true
when: ansible_os_family == "Debian"
- name: Install Docker on RHEL family
dnf:
name:
- docker
- docker-compose-plugin
state: present
when: ansible_os_family == "RedHat"
- name: Enable and start Docker
service:
name: docker
state: started
enabled: true
- name: Create application directory
file:
path: "{{ app_root }}"
state: directory
mode: "0755"
- name: Write Docker Compose file
copy:
dest: "{{ app_root }}/docker-compose.yml"
mode: "0644"
content: |
services:
mautic:
image: mautic/mautic:{{ mautic_version }}
container_name: mautic
restart: unless-stopped
ports:
- "{{ app_port }}:80"
environment:
- MAUTIC_DB_HOST=db
- MAUTIC_DB_NAME=mautic
- MAUTIC_DB_USER=mautic
- MAUTIC_DB_PASSWORD={{ mautic_db_password }}
- MAUTIC_RUN_CRON_JOBS=true
volumes:
- mautic_data:/var/www/html
depends_on:
- db
db:
image: mariadb:10.11
container_name: mautic-db
restart: unless-stopped
environment:
- MYSQL_ROOT_PASSWORD={{ mautic_db_root_password }}
- MYSQL_DATABASE=mautic
- MYSQL_USER=mautic
- MYSQL_PASSWORD={{ mautic_db_password }}
volumes:
- db_data:/var/lib/mysql
volumes:
mautic_data:
db_data:
- name: Start application stack
command: docker compose up -d
args:
chdir: "{{ app_root }}"
mautic/mautic on Docker Hublatesthttp://your-server:8080http://your-server:8080Any questions?
Feel free to contact us. Find all contact information on our contact page.