community.general.django_manage – Manages a Django application.¶
Note
This plugin is part of the community.general collection (version 2.5.1).
To install it use: ansible-galaxy collection install community.general
.
To use it in a playbook, specify: community.general.django_manage
.
Synopsis¶
Manages a Django application using the
manage.py
application frontend todjango-admin
. With thevirtualenv
parameter, all management commands will be executed by the givenvirtualenv
installation.
Requirements¶
The below requirements are needed on the host that executes this module.
virtualenv
django
Parameters¶
Notes¶
Note
virtualenv
(http://www.virtualenv.org) must be installed on the remote host if the virtualenv parameter is specified.This module will create a virtualenv if the virtualenv parameter is specified and a virtualenv does not already exist at the given location.
This module assumes English error messages for the
createcachetable
command to detect table existence, unfortunately.To be able to use the
migrate
command with django versions < 1.7, you must havesouth
installed and added as an app in your settings.To be able to use the
collectstatic
command, you must have enabled staticfiles in your settings.Your
manage.py
application must be executable (rwxr-xr-x), and must have a valid shebang, i.e.#!/usr/bin/env python
, for invoking the appropriate Python interpreter.
Examples¶
- name: Run cleanup on the application installed in django_dir
community.general.django_manage:
command: cleanup
project_path: "{{ django_dir }}"
- name: Load the initial_data fixture into the application
community.general.django_manage:
command: loaddata
project_path: "{{ django_dir }}"
fixtures: "{{ initial_data }}"
- name: Run syncdb on the application
community.general.django_manage:
command: syncdb
project_path: "{{ django_dir }}"
settings: "{{ settings_app_name }}"
pythonpath: "{{ settings_dir }}"
virtualenv: "{{ virtualenv_dir }}"
- name: Run the SmokeTest test case from the main app. Useful for testing deploys
community.general.django_manage:
command: test
project_path: "{{ django_dir }}"
apps: main.SmokeTest
- name: Create an initial superuser
community.general.django_manage:
command: "createsuperuser --noinput --username=admin [email protected]"
project_path: "{{ django_dir }}"
Authors¶
Scott Anderson (@tastychutney)