Operations 10 min read

Deploy a Mezzanine Blog with Ansible and Docker: Step‑by‑Step Guide

This article walks through building a Mezzanine CMS blog, first manually on macOS, then automating the deployment with Ansible, refactoring using roles, and finally containerizing the setup with Docker, providing detailed commands, configuration files, and best‑practice tips for production environments.

MaGe Linux Operations
MaGe Linux Operations
MaGe Linux Operations
Deploy a Mezzanine Blog with Ansible and Docker: Step‑by‑Step Guide

This article documents a practical example of deploying a blog site using Ansible, illustrating the process in four parts.

1 Manual Setup of Mezzanine

Before configuration‑management tools, the author manually installs Mezzanine (a Django‑based CMS) on macOS 10.12. The steps include installing virtualenv, creating a virtual environment, installing the Mezzanine module, creating a project, initializing the database, and running the development server on port 8000.

Images show the virtualenv installation and the running Django application.

For production, considerations include switching from SQLite to PostgreSQL or MySQL, using a dedicated web server (nginx) for static files, employing a WSGI server such as gunicorn or uwsgi, enabling HTTPS, and managing the gunicorn process with a supervisor.

2 Ansible Deployment of Mezzanine

The author sets up a test environment using VirtualBox and Vagrant, creating Ubuntu 14.04 virtual machines. Commands used:

vagrant box add ubuntu/trusty64 ~/Downloads/virtualbox.box
vagrant init ubuntu/trusty64
# edit Vagrantfile to add private IP 192.168.56.18
vagrant up
vagrant ssh

An Ansible configuration file (ansible.cfg) specifies the inventory file, remote user, private key, and disables host key checking. The inventory lists the target host and SSH port.

The main playbook mezzanine.yml installs PostgreSQL, configures nginx as a reverse proxy, deploys the Mezzanine code, and runs gunicorn under supervisor. After running ansible-playbook mezzanine.yml, the site is reachable at http://192.168.56.18.xip.io.

3 Refactor Playbook with Roles

To improve maintainability, the author rewrites the deployment using standard Ansible role structure, separating database and web responsibilities into distinct roles and moving handlers into handlers directories. The Vagrantfile now defines two virtual machines, one for the database and one for the web server. The role aptsource customizes sources.list to speed up package installation.

4 Deploy Mezzanine with Docker

Because Docker runs only on Linux, the author uses the same Ubuntu VM to install Docker, python‑dev, and Ansible (v2.2.0). Docker‑related modules have shifted to docker_container and docker_image. The Docker deployment consists of Dockerfiles for building images and an Ansible playbook that builds the images, creates containers, and starts services.

Key points include using ports for container port mapping, volumes_from for data volumes, links for inter‑container networking, setting detach=False for commands that must run in the foreground, and using publish_all_ports: True for the PostgreSQL container.

Running ansible-playbook run-mezzanine.yml builds the images and starts the containers; docker ps shows running containers and docker exec -it <container> /bin/bash provides shell access.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

DockerDeploymentDevOpsDjangoAnsibleMezzanine
MaGe Linux Operations
Written by

MaGe Linux Operations

Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.