Background Image
Table of Contents Table of Contents
Previous Page  451 / 478 Next Page
Information
Show Menu
Previous Page 451 / 478 Next Page
Page Background

APPENDIX C

Provisioning with Ansible

We used Fabric to automate deploying new versions of the source code to our servers.

But provisioning a fresh server, and updating the Nginx and Gunicorn config files, was

all left as a manual process.

This is the kind of job that’s increasingly given to tools called “Configuration Manage‐

ment” or “Continuous Deployment” tools. Chef and Puppet were the first popular ones,

and in the Python world there’s Salt and Ansible.

Of all of these, Ansible is the easiest to get started with. We can get it working with just

two files:

pip install ansible # Python 2 sadly

An “inventory file” at

deploy_tools/inventory.ansible

defines what servers we can

run against:

deploy_tools/inventory.ansible.

[live]

superlists.ottg.eu

[staging]

superlists-staging.ottg.eu

[local]

localhost ansible_ssh_port

=

6666 ansible_host=127.0.0.1

(The local entry is just an example, in my case a Virtualbox VM, with port forwarding

for ports 22 and 80 set up.)

Installing System Packages and Nginx

Next the Ansible “playbook”, which defines what to do on the server. This uses a syntax

called YAML:

423