Chapter 6. Introducing Mezzanine: Our Test Application

Chapter 3 covered the basics of writing playbooks. But real life is always messier than the introductory chapters of programming books, so in this chapter we’re going to work through a complete example of deploying a nontrivial application. In the next chapter we will do the implementation.

Our example application is an open source content management system (CMS) called Mezzanine, which is similar in spirit to WordPress. Mezzanine is built on top of Django, the free Python-based framework for writing web applications.

Why Is Deploying to Production Complicated?

Let’s take a little detour and talk about the differences between running software in development mode on your laptop versus running the software in production. Mezzanine is a great example of an application that is much easier to run in development mode than it is to deploy. Example 6-1 shows a provisioning script to get Mezzanine running on Ubuntu Focal/64.1

Example 6-1. Running Mezzanine in development mode
$ sudo apt-get install -y python3-venv
$ python3 -m venv venv
$ source venv/bin/activate
$ pip3 install wheel
$ pip3 install mezzanine
$ mezzanine-project myproject
$ cd myproject
$ sed -i 's/ALLOWED_HOSTS = \[\]/ALLOWED_HOSTS = ["*"]/' myproject/settings.py
$ python manage.py migrate
$ python manage.py runserver 0.0.0.0:8000

You should eventually see output on the terminal that looks like this:

 ..... _d^^^^^^^^^b_ .d'' ``b. .p' `q. .d' `b. .d' `b. * Mezzanine ...

Get Ansible: Up and Running, 3rd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.