Giter Site home page Giter Site logo

django-ansible-deploy's Introduction

Demonstrative Ansible playbook to deploy a Django project

For PyCon 8, Florence, April 2017

The pycon8 folder includes a single Django project having a single app, a single model and a single view. That project features the minimal setup required to make it easy deployable with PIP and uses environment variables for configuration.

The deploy folder contains a bunch of Ansible playbooks to configure the servers and deploy the project using the following technologies:

  • CentOS 7
  • NGiNX
  • uWSGI
  • Python 3.6
  • PostgreSQL

To install a local development environment clone the repo and create a virtual environment with Python 3.6, then run the command:

pip install -r requirements/local.txt

To create an installation bundle in the deploy/files folder you can run the following command:

invoke build --bundle

To create two local CentOS virtual machines use the provided Vagrantfile tested with the VirtualBox provider:

cd deploy
vagrant up

To run the Ansible playbook a [virtual] environment with Python 2.7 is required, until Ansible will be fully compatible with Python 3.

To configure the project for the local environment create and edit the dotenv file in the deploy/files folder copying it from the .env.example file:

cp .env.example deploy/files/pycon8.env

Then to deploy on the two local Vagrant boxes run the main playbook:

ansible-playbook -i hosts/local all_servers.yml --extra-vars "pycon8=0.1.0" -vvv

The two CentOS 7 machines will be configured as web server and database server and the project will be deployed using the installation bundle.

Using the git_repo variable it is possible to deploy in the target machines directly from GIT and PyPI:

ansible-playbook -i hosts/local web_servers_git.yml --extra-vars "pycon8=master" -vvv

Using tags it is possible to perform a deploy, skipping all the configuration steps and without any internet access:

ansible-playbook -i hosts/local web_servers.yml --extra-vars "pycon8=0.1.0" --tags=deploy -vvv

django-ansible-deploy's People

Contributors

marco-santamaria avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

django-ansible-deploy's Issues

Unable to SSH during `vagrant up`

@marco-santamaria Thanks for the helpful repository, I really like your approach.

Unfortunately I was unable to test it as I can't create Vagrant machines:

air:deploy user$ vagrant up
Bringing machine 'web' up with 'virtualbox' provider...
Bringing machine 'db' up with 'virtualbox' provider...
==> web: Checking if box 'centos/7' is up to date...
==> web: Clearing any previously set network interfaces...
==> web: Preparing network interfaces based on configuration...
    web: Adapter 1: nat
    web: Adapter 2: hostonly
==> web: Forwarding ports...
    web: 80 (guest) => 8080 (host) (adapter 1)
    web: 22 (guest) => 2222 (host) (adapter 1)
==> web: Booting VM...
==> web: Waiting for machine to boot. This may take a few minutes...
    web: SSH address: 127.0.0.1:2222
    web: SSH username: vagrant
    web: SSH auth method: private key
    web: Warning: Connection reset. Retrying...
    web: Warning: Remote connection disconnect. Retrying...
    web: Warning: Connection reset. Retrying...

Looks like something was changed in the default auth method (which is now private key).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.