Forge Home

django

Manages deployed Django apps

10,853 downloads

5,800 latest version

4.2 quality score

We run a couple of automated
scans to help you access a
module's quality. Each module is
given a score based on how well
the author has formatted their
code and documentation and
modules are also checked for
malware using VirusTotal.

Please note, the information below
is for guidance only and neither of
these methods should be considered
an endorsement by Puppet.

Version information

  • 0.1.4 (latest)
  • 0.1.2
  • 0.1.1
  • 0.1.0 (deleted)
released Mar 18th 2018
This version is compatible with:

Start using this module

  • r10k or Code Manager
  • Bolt
  • Manual installation
  • Direct download

Add this module to your Puppetfile:

mod 'node13h-django', '0.1.4'
Learn more about managing modules with a Puppetfile

Add this module to your Bolt project:

bolt module add node13h-django
Learn more about using this module with an existing project

Manually install this module globally with Puppet module tool:

puppet module install node13h-django --version 0.1.4

Direct download is not typically how you would use a Puppet module to manage your infrastructure, but you may want to download the module in order to inspect the code.

Download

Documentation

node13h/django — version 0.1.4 Mar 18th 2018

Django module for Puppet

Manages deployed Django apps and related stuff

Features

  • Supports multiple Django applications on the same server
  • Manages application processes with Supervisord
  • Supports per-app virtualenvs
  • Installs application-related OS packages
  • Manages user accounts and deployment ssh keys
  • Manages Celery workers and beat
  • Supports environment variable definition from .env file placed in srcdir (like Heroku Foreman)
  • ENC-friendly
  • Sane defaults which can be overriden

Usage

  • Application code by default is expected at /home/username/Sites/appname/base (customizable)
  • virtualenv by default is expected at /home/username/Sites/appname/venv (customizable)
  • for apps - gunicorn package is expected in virtualenv (add to your requirements.txt)
  • setproctitle package is optional in virtualenv
  • apps, workers and beats may reside on different nodes

  class { '::django':
    apps    => {
      polls => {
        user  => 'bob',
      },
    },

More complex example


  class { '::django':
    apps    => {
      polls => {
        user  => 'bob',
        bind  => '127.0.0.1:8000',
      },
    },
    workers => {
      worker1 => {
        user => 'bob',
        app  => 'polls',
      },
    },
    beats    => {
      polls => {
        user             => 'bob',
        schedule_db_file => '/home/users/bob/Sites/polls/run/beat-schedule',
        pidfile          => '/home/users/bob/Sites/polls/run/celerybeat.pid',
      },
    },
    packages => [
      'python-pip',
      'python-virtualenv',
      'libpq-dev',
      'python-dev',
      'git',
      'libwebp-dev',
      'liblcms2-dev',
      'libtiff5-dev',
      'libfreetype6-dev',
      'zlib1g-dev',
      'liblcms1-dev',
    ],
    users     => {
      bob => {
        comment => 'Polls app server user',
        home    => '/home/bob',
      },
    },
    keys      => {
      'developer-john-pubkey' => {
        key  => 'pubkey-pubkey-pubkey-pubkey-pubkey-pubkey-pubkey-pubkey-pubkey-pubkey',
        user => 'bob',
      },
      'developer-alice-pubkey' => {
        key  => 'pubkey-pubkey-pubkey-pubkey-pubkey-pubkey-pubkey-pubkey-pubkey-pubkey',
        user => 'bob',
      },
    },
  }

Defaults can be overriden


  class { '::django':
    apps    => {
      testapp => {
        user               => 'jack',
        bind               => '127.0.0.1:8000',
        launcher_overrides => {
          srcdir          => '/srv/apps/testapp',
          virtualenv      => '/home/jack/.virtualenvs/testenv',
          settings_module => 'testapp.local_settings',
        },
      },
    },
  }

Suggested workflow

  • Declare django class in node definition
  • After puppet sets up users, keys and directories - create virtualenv in expected directory and deploy code in srcdir (see above example)

Multiple apps and multiple users are supported


  class { '::django':
    apps    => {
      app1 => {
        user        => 'bob',
        bind        => '127.0.0.1:8000',
        num_workers => 1,
      },
      app2 => {
        user           => 'bob',
        bind           => '127.0.0.1:8001',
        wsgi_server    => 'custom',
        custom_command => 'fab runmyserver',
        log_level      => 'debug',
      },
      app3 => {
        user  => 'jack',
        bind  => '127.0.0.1:8002',
      },
      app4 => {
        user  => 'alreadyexistinguser',
        bind  => '127.0.0.1:8003',
      },
    },
    users     => {
      bob => {
        comment => 'app1 and app2 server user',
        home    => '/home/bob',
      },
      jack => {
        comment => 'app3 server user',
        home    => '/home/jack',
      },
    },
  }