mirror of
https://github.com/ansible/awx.git
synced 2026-02-03 18:48:12 -03:30
Simplify Django organization, add South support.
This commit is contained in:
66
app_setup/setup.yml
Normal file
66
app_setup/setup.yml
Normal file
@@ -0,0 +1,66 @@
|
||||
---
|
||||
|
||||
# tested only on CentOS6, may need adaptations for other operating systems
|
||||
# TODO: install any ansible plugins we need
|
||||
# TODO: set up Apache or Nginx to proxy this application
|
||||
# TODO: setup celery and any worker processes/requirements
|
||||
|
||||
- hosts: 127.0.0.1
|
||||
gather_facts: True
|
||||
user: root
|
||||
vars_files:
|
||||
- vars/vars.yml
|
||||
|
||||
tasks:
|
||||
|
||||
- name: install packages
|
||||
action: yum name=$item state=installed
|
||||
with_items:
|
||||
- postgresql # database client
|
||||
- postgresql-server # database server
|
||||
- Django # web stack
|
||||
- Django-south # migration support
|
||||
- python-django-tastypie # rest support
|
||||
- python-psycopg2
|
||||
|
||||
# the following could probably be included, though ident identification is fiddly
|
||||
# so we won't use it to create the database and database user
|
||||
|
||||
- name: configure the database authentication more or less open for setup
|
||||
template: src=templates/pg_hba_low.j2 dest=/var/lib/pgsql/data/pg_hba.conf
|
||||
|
||||
- name: restart postgresql
|
||||
service: name=postgresql state=restarted
|
||||
|
||||
- name: setup the postgresql user
|
||||
postgresql_user: >
|
||||
name=ansible_commander
|
||||
db=ansible_commander
|
||||
password=${database_password}
|
||||
login_user=postgres
|
||||
priv=ALL
|
||||
sudo_user: postgres
|
||||
|
||||
- name: create the database
|
||||
postgresql_db: name=acom state=present
|
||||
|
||||
- name: configure the database authentication for runtime mode
|
||||
template: src=templates/pg_hba.j2 dest=/var/lib/pgsql/data/pg_hba.conf
|
||||
|
||||
- name: restart postgresql
|
||||
service: name=postgresql state=restarted
|
||||
|
||||
- name: configure python settings (with database password)
|
||||
template: src=templates/settings.py.j2 dest=${working_dir}/acom/settings.py
|
||||
|
||||
- name: sync Django database
|
||||
shell: python ${working_dir}/acom/manage.py syncdb
|
||||
|
||||
- name: sync django database
|
||||
django_manage: >
|
||||
command=syncdb
|
||||
app_path=${working_dir}/acom
|
||||
|
||||
#- name: run south migrations
|
||||
# command: python ${working_dir}/acom/manage.py migrate db_migrate
|
||||
|
||||
5
app_setup/templates/config.j2
Normal file
5
app_setup/templates/config.j2
Normal file
@@ -0,0 +1,5 @@
|
||||
[database]
|
||||
password={{ database_password }}
|
||||
|
||||
[inventory]
|
||||
secret=TheEnemysGateisDown
|
||||
53
app_setup/templates/db.j2
Normal file
53
app_setup/templates/db.j2
Normal file
@@ -0,0 +1,53 @@
|
||||
CREATE USER ansible_commander UNENCRYPTED PASSWORD '{{ database_password }}';
|
||||
|
||||
GRANT ALL on DATABASE ansible_commander TO ansible_commander;
|
||||
GRANT ALL on DATABASE ansible_commander_test TO ansible_commander;
|
||||
|
||||
\c ansible_commander
|
||||
|
||||
CREATE TABLE thing
|
||||
(
|
||||
id BIGSERIAL PRIMARY KEY,
|
||||
type TEXT
|
||||
);
|
||||
|
||||
CREATE TABLE properties
|
||||
(
|
||||
id BIGSERIAL PRIMARY KEY,
|
||||
thing_id BIGSERIAL NOT NULL REFERENCES thing(id) ON DELETE CASCADE,
|
||||
key TEXT NOT NULL,
|
||||
value TEXT
|
||||
);
|
||||
|
||||
CREATE UNIQUE INDEX properties_thing_idx ON properties (thing_id, key);
|
||||
CREATE INDEX properties_key_idx ON properties (key);
|
||||
CREATE INDEX properties_value_idx ON properties (key, value);
|
||||
GRANT ALL on TABLE thing TO ansible_commander;
|
||||
GRANT ALL on TABLE properties TO ansible_commander;
|
||||
GRANT ALL ON SEQUENCE thing_id_seq TO ansible_commander;
|
||||
GRANT ALL ON SEQUENCE properties_id_seq TO ansible_commander;
|
||||
|
||||
\c ansible_commander_test
|
||||
|
||||
CREATE TABLE thing
|
||||
(
|
||||
id BIGSERIAL PRIMARY KEY,
|
||||
type TEXT
|
||||
);
|
||||
|
||||
CREATE TABLE properties
|
||||
(
|
||||
id BIGSERIAL PRIMARY KEY,
|
||||
thing_id BIGSERIAL NOT NULL REFERENCES thing(id) ON DELETE CASCADE,
|
||||
key TEXT NOT NULL,
|
||||
value TEXT
|
||||
);
|
||||
|
||||
CREATE UNIQUE INDEX properties_thing_idx ON properties (thing_id, key);
|
||||
CREATE INDEX properties_key_idx ON properties (key);
|
||||
CREATE INDEX properties_value_idx ON properties (key, value);
|
||||
GRANT ALL on TABLE thing TO ansible_commander;
|
||||
GRANT ALL on TABLE properties TO ansible_commander;
|
||||
GRANT ALL ON SEQUENCE thing_id_seq TO ansible_commander;
|
||||
GRANT ALL ON SEQUENCE properties_id_seq TO ansible_commander;
|
||||
|
||||
7
app_setup/templates/pg_hba.j2
Normal file
7
app_setup/templates/pg_hba.j2
Normal file
@@ -0,0 +1,7 @@
|
||||
# Database administrative login by UNIX sockets
|
||||
local all postgres ident
|
||||
|
||||
# TYPE DATABASE USER CIDR-ADDRESS METHOD
|
||||
local all all md5
|
||||
host all all 127.0.0.1/32 md5
|
||||
host all all ::1/128 md5
|
||||
5
app_setup/templates/pg_hba_low.j2
Normal file
5
app_setup/templates/pg_hba_low.j2
Normal file
@@ -0,0 +1,5 @@
|
||||
# temporary security setup for initial config only
|
||||
|
||||
# TYPE DATABASE USER CIDR-ADDRESS METHOD
|
||||
local all postgres trust
|
||||
|
||||
99
app_setup/templates/settings.py.j2
Normal file
99
app_setup/templates/settings.py.j2
Normal file
@@ -0,0 +1,99 @@
|
||||
# Django settings for acom project.
|
||||
|
||||
DEBUG = True
|
||||
TEMPLATE_DEBUG = DEBUG
|
||||
|
||||
ADMINS = (
|
||||
# ('Your Name', 'your_email@domain.com'),
|
||||
)
|
||||
|
||||
MANAGERS = ADMINS
|
||||
|
||||
DATABASES = {
|
||||
'default': {
|
||||
'ENGINE': 'postgresql_psycopg2',
|
||||
'NAME': 'acom',
|
||||
'USER': 'ansible_commander',
|
||||
'PASSWORD': '{{ database_password }}',
|
||||
'HOST': '',
|
||||
'PORT': '',
|
||||
}
|
||||
}
|
||||
|
||||
# Local time zone for this installation. Choices can be found here:
|
||||
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
|
||||
# although not all choices may be available on all operating systems.
|
||||
# On Unix systems, a value of None will cause Django to use the same
|
||||
# timezone as the operating system.
|
||||
# If running in a Windows environment this must be set to the same as your
|
||||
# system time zone.
|
||||
TIME_ZONE = 'America/New_York'
|
||||
|
||||
# Language code for this installation. All choices can be found here:
|
||||
# http://www.i18nguy.com/unicode/language-identifiers.html
|
||||
LANGUAGE_CODE = 'en-us'
|
||||
|
||||
SITE_ID = 1
|
||||
|
||||
# If you set this to False, Django will make some optimizations so as not
|
||||
# to load the internationalization machinery.
|
||||
USE_I18N = True
|
||||
|
||||
# If you set this to False, Django will not format dates, numbers and
|
||||
# calendars according to the current locale
|
||||
USE_L10N = True
|
||||
|
||||
# Absolute filesystem path to the directory that will hold user-uploaded files.
|
||||
# Example: "/home/media/media.lawrence.com/"
|
||||
MEDIA_ROOT = ''
|
||||
|
||||
# URL that handles the media served from MEDIA_ROOT. Make sure to use a
|
||||
# trailing slash if there is a path component (optional in other cases).
|
||||
# Examples: "http://media.lawrence.com", "http://example.com/media/"
|
||||
MEDIA_URL = ''
|
||||
|
||||
# URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a
|
||||
# trailing slash.
|
||||
# Examples: "http://foo.com/media/", "/media/".
|
||||
ADMIN_MEDIA_PREFIX = '/media/'
|
||||
|
||||
# Make this unique, and don't share it with anybody.
|
||||
SECRET_KEY = 'p7z7g1ql4%6+(6nlebb6hdk7sd^&fnjpal308%n%+p^_e6vo1y'
|
||||
|
||||
# List of callables that know how to import templates from various sources.
|
||||
TEMPLATE_LOADERS = (
|
||||
'django.template.loaders.filesystem.Loader',
|
||||
'django.template.loaders.app_directories.Loader',
|
||||
# 'django.template.loaders.eggs.Loader',
|
||||
)
|
||||
|
||||
MIDDLEWARE_CLASSES = (
|
||||
'django.middleware.common.CommonMiddleware',
|
||||
'django.contrib.sessions.middleware.SessionMiddleware',
|
||||
'django.middleware.csrf.CsrfViewMiddleware',
|
||||
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
||||
'django.contrib.messages.middleware.MessageMiddleware',
|
||||
)
|
||||
|
||||
ROOT_URLCONF = 'acom.urls'
|
||||
|
||||
TEMPLATE_DIRS = (
|
||||
# Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
|
||||
# Always use forward slashes, even on Windows.
|
||||
# Don't forget to use absolute paths, not relative paths.
|
||||
)
|
||||
|
||||
INSTALLED_APPS = (
|
||||
'django.contrib.auth',
|
||||
'django.contrib.contenttypes',
|
||||
'django.contrib.sessions',
|
||||
'django.contrib.sites',
|
||||
'django.contrib.messages',
|
||||
'main',
|
||||
'south',
|
||||
|
||||
# Uncomment the next line to enable the admin:
|
||||
#'django.contrib.admin',
|
||||
# Uncomment the next line to enable admin documentation:
|
||||
# 'django.contrib.admindocs',
|
||||
)
|
||||
2
app_setup/vars/vars.yml
Normal file
2
app_setup/vars/vars.yml
Normal file
@@ -0,0 +1,2 @@
|
||||
---
|
||||
database_password: gateIsDown
|
||||
Reference in New Issue
Block a user