community.general.django_manage (1.3.11) — module

Manages a Django application.

Authors: Scott Anderson (@tastychutney)

Install collection

Install with ansible-galaxy collection install community.general:==1.3.11


Add to requirements.yml

  collections:
    - name: community.general
      version: 1.3.11

Description

Manages a Django application using the C(manage.py) application frontend to C(django-admin). With the C(virtualenv) parameter, all management commands will be executed by the given C(virtualenv) installation.


Requirements

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Run cleanup on the application installed in django_dir
  community.general.django_manage:
    command: cleanup
    project_path: "{{ django_dir }}"
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Load the initial_data fixture into the application
  community.general.django_manage:
    command: loaddata
    project_path: "{{ django_dir }}"
    fixtures: "{{ initial_data }}"
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- 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 }}"
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- 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
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Create an initial superuser
  community.general.django_manage:
    command: "createsuperuser --noinput --username=admin --email=admin@example.com"
    project_path: "{{ django_dir }}"

Inputs

    
apps:
    description:
    - A list of space-delimited apps to target. Used by the C(test) command.
    required: false
    type: str

link:
    description:
    - Will create links to the files instead of copying them, you can only use this parameter
      with C(collectstatic) command.
    required: false
    type: bool

skip:
    description:
    - Will skip over out-of-order missing migrations, you can only use this parameter
      with C(migrate) command.
    required: false
    type: bool

clear:
    default: false
    description:
    - Clear the existing files before trying to copy or link the original file.
    - Used only with the 'collectstatic' command. The C(--noinput) argument will be added
      automatically.
    required: false
    type: bool

merge:
    description:
    - Will run out-of-order or missing migrations as they are not rollback migrations,
      you can only use this parameter with C(migrate) command.
    required: false
    type: bool

command:
    description:
    - The name of the Django management command to run. Built in commands are C(cleanup),
      C(collectstatic), C(flush), C(loaddata), C(migrate), C(syncdb), C(test), and C(validate).
    - Other commands can be entered, but will fail if they're unknown to Django.  Other
      commands that may prompt for user input should be run with the C(--noinput) flag.
    - The module will perform some basic parameter validation (when applicable) to the
      commands C(cleanup), C(collectstatic), C(createcachetable), C(flush), C(loaddata),
      C(migrate), C(syncdb), C(test), and C(validate).
    required: true
    type: str

database:
    description:
    - The database to target. Used by the C(createcachetable), C(flush), C(loaddata),
      C(syncdb), and C(migrate) commands.
    required: false
    type: str

failfast:
    aliases:
    - fail_fast
    default: false
    description:
    - Fail the command immediately if a test fails. Used by the C(test) command.
    required: false
    type: bool

fixtures:
    description:
    - A space-delimited list of fixture file names to load in the database. B(Required)
      by the C(loaddata) command.
    required: false
    type: str

settings:
    description:
    - The Python path to the application's settings module, such as C(myapp.settings).
    required: false
    type: path

liveserver:
    aliases:
    - live_server
    description:
    - This parameter was implemented a long time ago in a galaxy far way. It probably
      relates to the django-liveserver package, which is no longer updated.
    - Hence, it will be considered DEPRECATED and should be removed in a future release.
    required: false
    type: str

pythonpath:
    aliases:
    - python_path
    description:
    - A directory to add to the Python path. Typically used to include the settings module
      if it is located external to the application directory.
    required: false
    type: path

testrunner:
    aliases:
    - test_runner
    description:
    - 'From the Django docs: Controls the test runner class that is used to execute tests.'
    - This parameter is passed as-is to C(manage.py).
    required: false
    type: str

virtualenv:
    aliases:
    - virtual_env
    description:
    - An optional path to a I(virtualenv) installation to use while running the manage
      application.
    type: path

cache_table:
    description:
    - The name of the table used for database-backed caching. Used by the C(createcachetable)
      command.
    required: false
    type: str

project_path:
    aliases:
    - app_path
    - chdir
    description:
    - The path to the root of the Django application where B(manage.py) lives.
    required: true
    type: path