Ansible role to prepare the launch of a Django app on a Plesk managed Ubuntu server:
- installs important packages
- imports timezone data to MySQL (optional)
- setup virtualenv (optional)
- python-pip
- python-dev
- build-essential
- python-django (for django-admin bash autocomplete register only)
- python-mysqldb (for MySQL only)
- libmysqlclient-dev (or get error mysql_config not found)
- libapache2-mod-wsgi
- virtualenvwrapper
- libjpeg-dev (for Pillow, or get error decoder JPEG not available)
- python3-dev (for Python 3)
- upgrade pip
If the tzinfo data is missing from mysql, a ValueError
occurs
(see official mysql docs, relevant tzinfo blog, how to check tzinfo, how to set tzinfo).
Create a directory to keep all virtualenvs and prepare bash profile for the user.
To use, add the role django-prepare
.
ansible_user_id
: The user id with access to mysql and mysql database.mysql_pass
: MySQL password (better obtain from vault or prompt in playbook). Omit to skip mysql import of data.virtualenv_dir
: Virtualenvs home directory. Set tofalse
to disable virtualenv. Default:/var/virtualenvs
.plesk_server_group
: Plesk server group, default:psaserv
.
Plain:
---
- hosts: servers
roles:
- django-prepare
Specify variables:
---
- hosts: servers
gather_facts: no
roles:
- role: django-prepare
virtualenv_dir: ~/.virtualenvs
See more roles regarding Django on https://galaxy.ansible.com/Wtower/