Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Example of creating Django superuser (with password) in dev environment using SaltStack
import os
import sys
# First, add the project to PATH. Adjust as needed.
PWD = os.path.dirname(os.path.abspath(__file__))
PROJECT_PATH = os.path.abspath(os.path.join(PWD, '../../../../'))
# Second, configure this script to use Django
import django
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'project.settings')
except AttributeError:
print django.VERSION
from import changepassword
from django.core import management
# Create the super user and sets his password.
management.call_command('createsuperuser', interactive=False, username="admin", email="")
command = changepassword.Command()
command._get_pass = lambda *args: 'password'
# If you have multiple environments in SaltStack you can states based
# on which env they are in. This is in my dev env.
# You will need to modify these two files accordingly.
# This could be a script.wait, but
- name: python salt/roots/dev/extra/
- cwd: {{ pillar.project_dir }}
- output_loglevel: quiet
- watch:
- postgres_database: state_to_create_db
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment