rm-software.django

Role Name

=========

Build and deploy a Django web application using Uwsgi, along with task management using Celery or Celerybeat.

Requirements


You need a set up Ubuntu server. Uwsgi requires a WSGI proxy through the Nginx role.

Role Variables


By default, it will build a Django application but only deploy the Uwsgi web app.

django_webapp: yes
django_taskapp: no
django_beatapp: no
django_monitorapp: no
django_flowerapp: no

These are used as default settings for virtual environments, local clones, database user, name, password, etc. Values should be alphanumeric, can include underscores, and should be valid for database names and directories.

django_project_name: django

# The project will be cloned to:
# {{ django_project_home }}/{{ django_project_name }}
django_project_home: '{{ ansible_env.HOME }}'

# Source code repository, branch, and directories
django_repo_url: ssh://[email protected]/myawesomeproject
django_repo_version: default
django_repo_type: git
django_local_repo: '{{ django_project_name }}'

# Domain and name (for Django default site, Nginx, etc.)
django_hostname: '{{ hostname }}'
django_project_description: '{{ description }}'

# Site secret
django_secret_key: 'changethesecretkeyforeachtarget'

# Must match a Django settings .py in config/settings, e.g., 'dev'
django_settings_module: 'config.settings.production'

# Pip install requirements
django_pip_requirements: production.txt

# Database settings
django_db_host: localhost
django_db_user: '{{ django_project_name }}'
django_db_name:  '{{ django_project_name }}'
django_db_password:  '{{ django_project_name }}'
django_db_superuser: postgres
django_db_superpassword: postgres
django_db_locale: en_US.UTF-8

# Rarely changed settings
django_upstream_hostkey: bitbucket.org ssh-rsa AAAAB3NzaC1yc2...
django_wsgi_addr: '{{ ansible_lo.ipv4.address }}'
django_wsgi_port: 10000
django_uwsgi_processes: '{{ ansible_processor_cores }}'
django_uwsgi_harakiri: 60

# Paths
django_project_path: '{{ django_project_home }}/{{ django_project_name }}' # usually cdvirtualenv
django_log_path: '{{ django_project_path }}/log'
django_run_path: '{{ django_project_path }}/run'
django_media_root: '{{ django_project_path }}/media'
django_static_root: '{{ django_project_path }}/static'
django_repo_path: '{{ django_project_path }}/{{ django_project_name }}' # clone here
django_project_subdir: . # change if the django project is stored under a specific directory
django_path: '{{ django_repo_path }}/{{ django_project_subdir }}'
django_collectstatic_once: no # with WhiteNoise, must run collectstatic on all web app instances

# Standard Django environment settings variables
django_base_settings:
  DJANGO_SETTINGS_MODULE: '{{ django_settings_module }}'
  DJANGO_SECRET_KEY: '{{ django_secret_key }}'
  DATABASE_URL: 'postgres://{{ django_db_user }}:{{ django_db_password }}@{{ django_db_host }}/{{ django_db_name }}'

# Additional Django environment settings variables
django_extra_settings:

# Normally leave base packages as is; add new packages with `django_extra_apt_packages`
django_base_apt_packages:
  - gettext
  - python-psycopg2
  - zlib1g-dev
  - libpq-dev
  - libmysqlclient-dev
  - libtiff5-dev
  - libjpeg8-dev
  - libfreetype6-dev
  - liblcms2-dev
  - libwebp-dev
  - graphviz-dev
  - supervisor
  - emacs24-nox
  - redis-server

django_extra_apt_packages:

# Celery settings
celery_concurrency: '{{ ansible_processor_cores }}'
celery_numprocs: '{{ ansible_processor_cores }}'
celery_pool_implementation: prefork # options: prefork (default), eventlet, gevent, or solo
celery_beat_schedulers: django_celery_beat.schedulers:DatabaseScheduler

# Dependencies
------------

- rm-software.nginx
- rm-software.python
- rm-software.rabbitmq
- rm-software.redis
- rm-software.virtualenv

And a database server, either configured separately or via

- rm-software.postgresql

# Example Playbook
----------------

```yaml
- hosts: appservers
  tasks:
    - import_role:
        name: postgresql
      vars:
        postgresql_install_client: yes
    - import_role:
        name: python
    - import_role:
        name: virtualenv
    - import_role:
        name: django
      vars:
        django_webapp: yes
        django_taskapp: no
        django_beatapp: no

The majority of django_ variables should be set in group_vars.

Informazioni sul progetto

Django web, task and/or geat app installation

Installa
ansible-galaxy install rm-software.django
Licenza
apache-2.0
Download
119
Proprietario