How it works...

An Ansible script (a playbook) is idempotent. It means that you can execute it multiple times and you will always get the same results, an up-to-date dedicated server with Django website installed and running. If you have any technical hardware issues with the server and have backups of the database and media files, you can relatively quickly install the same configuration on another dedicated server.

The production deployment scripts do these things:

  • Set a hostname for the virtual machine
  • Upgrade the Linux packages
  • Set the localization settings for the server
  • Install all Linux dependencies such as Python, Nginx, PostgreSQL, Postfix, Memcached, and so on
  • Create a Linux user and home directory for the Django projec
  • Create a virtual environment for the Django project
  • Create the PostgreSQL database user and database
  • Configure the Nginx web server
  • Install the Let's Encrypt SSL certificate
  • Configure the Memcached caching service
  • Configure the Postfix email server
  • Clone the Django project repository
  • Install Python dependencies
  • Set up Gunicorn
  • Create the secrets.json file
  • Migrate the database
  • Collect static files
  • Restart Nginx

As you can see, the installation is very similar to the one on the staging server, but, to keep it flexible and more tweakable, we saved it separately in the deployment/production directory.

Theoretically, you could skip the staging environment altogether, but it is practical to try out the deployment procedure in a virtual machine rather than experimenting with installing directly on a remote server.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.23.101.60