How to do it...

First of all, we'll need to create some configuration templates for the different services used on the server. These will be used by both deployment procedures: staging and production.

  1. In your Django project, create a deployment directory and inside of it create an ansible_templates directory.
  1. Create a Jinja template file for time zone configuration:
{# deployment/ansible_templates/timezone.j2 #}{{ timezone }}
  1. Create a Jinja template file for Nginx domain configuration before setting the SSL certificates:
{# deployment/ansible_templates/nginx-pre.j2 #}server{    listen 80;    server_name {{ domain_name }};    location /.well-known/acme-challenge {        root /var/www/letsencrypt;        try_files $uri $uri/ =404;    }    location / { root /var/www/letsencrypt; ...

Get Django 3 Web Development Cookbook - Fourth 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.