Skip to content

Commit

Permalink
Move createsuperuser step into Ansible
Browse files Browse the repository at this point in the history
  • Loading branch information
berkerpeksag committed Feb 29, 2016
1 parent cdbb5be commit 9fe9bb1
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
8 changes: 7 additions & 1 deletion docs/source/install.rst
Expand Up @@ -23,7 +23,13 @@ Easy setup using Vagrant
The box will be provisioned by Ansible_ 1.9.3 with Python 3.4, a virtualenv
set up with requirements installed, and a database ready to use.

.. note:: You will need to run ``./manage.py createsuperuser`` to use the admin.
The box also creates a superuser with username ``cbiggles`` for you. However, you
will need to set a password before using it::

$ vagrant ssh
$ cd pythondotorg
$ . venv/bin/activate
$ ./manage.py changepassword cbiggles

.. note::

Expand Down
3 changes: 3 additions & 0 deletions provisioning/env_vars.yml
Expand Up @@ -11,6 +11,9 @@ project:
django:
settings: pydotorg.settings.local
fixtures: /home/vagrant/pythondotorg/fixtures/*.json
superuser:
name: cbiggles
email: cbiggless@example.com

database:
user: vagrant
Expand Down
11 changes: 11 additions & 0 deletions provisioning/pythondotorg.yml
Expand Up @@ -107,6 +107,17 @@
register: result
changed_when: "'No migrations to apply.' not in result.out"

- name: Create a superuser for Django admin
sudo: no
django_manage:
command="createsuperuser --noinput --username={{ django.superuser.name }} --email={{ django.superuser.email }}"
app_path={{ project.path }}
virtualenv={{ project.virtualenv }}
settings={{ django.settings }}
register: result
changed_when: "result.out is defined and 'Superuser created successfully' in result.out"
failed_when: "result.msg is defined and 'already exists' not in result.msg"

handlers:
- name: Restart PostgreSQL
service: name=postgresql state=restarted enabled=yes

0 comments on commit 9fe9bb1

Please sign in to comment.