Giter Site home page Giter Site logo

ansible-django's Introduction

ansible-django

Build Status

Use this role to install, configure, and manage Django.

This is a very simple and purist role for django installation. We only install and configure:

  • Django
  • Celery (optional)

We intentionally consider the installation and configuration of databases, web servers, and other things as out of scope for this role. Therefore, naturally this role is to be used in a playbook that installs and configures those other things.

Both Django and celery are installed and set up as systemd services.

Role Variables

Some of the more important variables are briefly described below. You can see all variables by looking at the defaults/main.yml file.

django_system_user: "django_app"  # name of the user that will own the django installation

django_python_source_version: "3.6"  # the python verion to user
django_python_version: "python3.6"  # the python version to use with pip commands

django_git_url: "https://github.com/moshthepitt/django-template3.git"  # the git repo of your django app which we are installing

django_local_settings_path: "path to /local_settings.py"  # Path to the Django settings file
django_settings_module: "template3.settings"  # Django settings module
django_wsgi_module: "template3.wsgi:application"  # Django wsgi module

You can look at tests/test.yml for examples of how to use these variables.

Django Settings

You can set any and all Django settings using the django_settings variable.

Here is a fairly simple example:

django_settings:
  BASE_DIR: "os.path.dirname(os.path.dirname(__file__))"
  SITE_ID: 1
  STATIC_ROOT: "'/var/www/static'"
  STATIC_URL: "'/static/'"
  MEDIA_ROOT: "'/var/www/media'"
  MEDIA_URL: "'/media/'"
  EMAIL_BACKEND: "'django.core.mail.backends.console.EmailBackend'"
  EMAIL_HOST: "'localhost'"
  EMAIL_PORT: "1025"
  DEFAULT_FROM_EMAIL: "'Hello World <[email protected]>'"
  ALLOWED_HOSTS: "[]"
  DEBUG: True

As you may have noticed the django_settings takes key: value arguments of the Django settings variables that we know and love.

For example, to set Debug=True, you would do:

django_settings:
  DEBUG: True

To set up your database, you'd do:

django_settings:
  DATABASES: |
    {
      'default': {
          'ENGINE': 'django.db.backends.postgresql',
          'NAME': 'somedb',
          'USER': 'someuser',
          'PASSWORD': 'hunter2',
          'HOST': '127.0.0.1',
          'PORT': '5432',
      }
    }

Role Dependencies

  • ANXS.python

You can install these by running the following ansible command:

ansible-galaxy install -r requirements.yml

Testing

This project comes with a Vagrantfile, this is a fast and easy way to test changes to the role, fire it up with vagrant up.

See vagrant docs for getting setup with vagrant

License

Apache 2

Authors

Ona Engineering

ansible-django's People

Contributors

bmarika avatar jasonrogena avatar morrismukiri avatar moshthepitt 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.