salt.pillar.django_orm¶
Generate pillar data from Django models through the Django ORM
maintainer: | Micah Hausler <micah.hausler@gmail.com> |
---|---|
maturity: | new |
Configuring the django_orm ext_pillar¶
To use this module, your Django project must be on the salt master server with database access. This assumes you are using virtualenv with all the project's requirements installed.
ext_pillar:
- django_orm:
pillar_name: my_application
project_path: /path/to/project/
settings_module: my_application.settings
env_file: /path/to/env/file.sh
# Optional: If your project is not using the system python, add your virtualenv path here
env: /path/to/virtualenv/
django_app:
# Required: the app that is included in INSTALLED_APPS
my_application.clients:
# Required: the model name
Client:
# Required: model field to use as a name in the
# rendered pillar, should be unique
name: shortname
# Optional:
# See Django's QuerySet documentation for how to use .filter()
filter: {'kw': 'args'}
# Required: a list of field names
fields:
- field_1
- field_2
This would return pillar data that would look like
my_application:
my_application.clients:
Client:
client_1:
field_1: data_from_field_1
field_2: data_from_field_2
client_2:
field_1: data_from_field_1
field_2: data_from_field_2
Module Documentation¶
-
salt.pillar.django_orm.
ext_pillar
(pillar, pillar_name, project_path, settings_module, django_app, env=None, env_file=None, *args, **kwargs)¶ Connect to a Django database through the ORM and retrieve model fields
Parameters: - pillar_name (str) -- The name of the pillar to be returned
- project_path (str) -- The full path to your Django project (the directory manage.py is in)
- settings_module (str) -- The settings module for your project. This can be found in your manage.py file
- django_app (str) -- A dictionary containing your apps, models, and fields
- env (str) -- The full path to the virtualenv for your Django project
- env_file (str) -- An optional bash file that sets up your environment. The file is run in a subprocess and the changed variables are then added