GithubHelp home page GithubHelp logo

savoirfairelinux / ansible-django Goto Github PK

View Code? Open in Web Editor NEW
16.0 16.0 2.0 85 KB

Provisions a Django project behind nginx/uwsgi

License: GNU General Public License v3.0

Shell 81.70% HTML 18.30%
ansible-role uwsgi nginx django

ansible-django's Introduction

ansible-django

Provisions a Django project behind nginx/uwsgi, SFL style.

Running this role results in a fully functional system that can run a Django instance behind nginx and uwsgi. This is used in SFL's project to provision local, staging and production Django instances. This role doesn't deploy the considered Django project (requirements installation, migrations, ...). To do so you should use the ansible-django-deploy role and insert it after this django role in your playbook.

Requirements

  • Ansible 2.2+
  • One of the supported target systems:
    • Ubuntu Xenial
    • Debian Jessie
  • For git deployment, you need git
  • For SSL with Let's Encrypt, you need ansible-acme-nginx
  • Nginx installed. Recommended role: ansible-nginx
  • MariaDB or PostgreSQL installed and running. Recommended roles:
  • For MariaDB, we expect passwordless login when root. It implies having a /root/.my.cnf.

Conventions

If django_provide_initial_data is set, we're expected to have a django_initial_data_restore_script that takes care of importing an initial DB dump and initial media files into our project. ansible-zbackup and ansible-backup-cron are well suited for this.

Usage

You call this role as with any other roles. See vars file for customisation options.

Here's an example usage for a local development environment:

---
- name: Install a fully functional Django/uwsgi/nginx
  hosts: django-dev

  roles:
    - role: django
      django_debug: yes
      django_user: vagrant
      django_project_symlink_dest: "/vagrant"

As you can see, we override django_debug because we're in development mode, and we use django_project_symlink_dest to set the project in "symlink mode", which allows us to trigger live reloads when we edit files on the host.

Features higlight

All details about the features below are accessibles in the variable files, but here's a highlight.

Postgres SQL or MariaDB

Your backend can be either Postgres SQL (default) or MariaDB. You can choose your DB with django_dbtype.

Git clone or symlink

The project's source that lives at django_project_path can be either from a git clone or a symlink. In a "real" environment, you'll want to clone from a git repo, but on a local environment, you'll want to symlink to your Vagrant share so that your changes to the code are taken into account immediately. See django_project_symlink_dest.

uwsgi touch reload

By default, uwsgi is set up with touch-reload set to the root directory of the project (the git checkout directory). This directory's mtime is generally changed whenever we make a git checkout. Therefore, with this setting, you shouldn't have to worry about reloading uwsgi after a deploy, it's done automatically.

ansible-django's People

Contributors

aaboffill avatar bardessaoli avatar desecho avatar ellmetha avatar peakwinter avatar pierreduchemin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

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.