django_manage – Manages a Django application¶
Synopsis¶
Manages a Django application using the manage.py application frontend to django-admin. With the virtualenv parameter, all management commands will be executed by the given virtualenv 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 have south 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.
As of ansible 2.x, 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¶
# Run cleanup on the application installed in 'django_dir'.
- django_manage:
command: cleanup
app_path: "{{ django_dir }}"
# Load the initial_data fixture into the application
- django_manage:
command: loaddata
app_path: "{{ django_dir }}"
fixtures: "{{ initial_data }}"
# Run syncdb on the application
- django_manage:
command: syncdb
app_path: "{{ django_dir }}"
settings: "{{ settings_app_name }}"
pythonpath: "{{ settings_dir }}"
virtualenv: "{{ virtualenv_dir }}"
# Run the SmokeTest test case from the main app. Useful for testing deploys.
- django_manage:
command: test
app_path: "{{ django_dir }}"
apps: main.SmokeTest
# Create an initial superuser.
- django_manage:
command: "createsuperuser --noinput --username=admin --email=admin@example.com"
app_path: "{{ django_dir }}"
Status¶
This module is not guaranteed to have a backwards compatible interface. [preview]
This module is maintained by the Ansible Community. [community]
Authors¶
Scott Anderson (@tastychutney)
Hint
If you notice any issues in this documentation, you can edit this document to improve it.