Commit 1427b373 authored by Georgios Ouzounis's avatar Georgios Ouzounis

LAM-53 Added templated settings.py. Merged django-install.yml to main.yml...

LAM-53 Added templated settings.py. Merged django-install.yml to main.yml task. Refactored handlers that migrate the databases.
parent 80f796f9
---
- name: django_db_migrate
- name: django_dbs_migrate
django_manage: command=migrate app_path={{ repository_download_path }}/okeanos-LoD/webapp/
changed_when: True
notify:
- makemigrations_backend_app
- name: makemigrations_backend_app
django_manage: command="makemigrations --noinput backend" app_path={{ repository_download_path }}/okeanos-LoD/webapp/
changed_when: True
notify:
- migrate_backend_app
- name: migrate_backend_app
django_manage: command=migrate app_path={{ repository_download_path }}/okeanos-LoD/webapp/backend
django_manage: command=migrate app_path={{ repository_download_path }}/okeanos-LoD/webapp/ apps=backend
---
- name: Install Django using Pip.
pip: name=Django
---
- name: Fix Debian locale error.
command: update-locale LANGUAGE="en_US.UTF-8" LC_ALL="en_US.UTF-8" #"echo 'LANGUAGE="en_US.UTF-8"' > /etc/default/locale && echo 'LC_ALL="en_US.UTF-8"' >> /etc/default/locale # The first redirection intentionally creates the file.
- name: Fix locale problem.
command: update-locale LANGUAGE="en_US.UTF-8" LC_ALL="en_US.UTF-8"
- name: Upgrade packages.
apt: upgrade=dist update_cache=yes
- name: Install python-pip, python-dev, sudo and git packages.
apt: name={{ item.name }} state=latest
apt: name={{ item }} state=latest
with_items:
- { name: 'python-pip' }
- { name: 'python-dev' }
- { name: 'sudo' }
- { name: 'git' }
- python-pip
- python-dev
- sudo
- git
- name: Create service user.
user: name={{ username }} shell=/bin/bash
......@@ -19,10 +19,17 @@
- name: Include postgresql-install tasks.
include: postgresql-install.yml
- name: Include django-install tasks.
include: django-install.yml
- name: Install Django using Pip.
pip: name=Django
- name: Download Django code from Github.
git: repo=https://github.com/gouzouni625/okeanos-LoD.git dest={{ repository_download_path }}/okeanos-LoD version=LAM-53-Django # version can be used to select a branch. See ansible git module documentation.
notify: # The repository should be changed when the pull request gets merged.
- django_db_migrate
# The repository should be changed when the pull request gets merged.
- name: Change repository permissions.
file: path={{ repository_download_path }} owner={{ username }} recurse=yes
- name: Setup Django database configuration.
template: src=settings.py.j2 dest={{ repository_download_path}}/okeanos-LoD/webapp/webapp/settings.py
notify:
- django_dbs_migrate
---
- name: Install PosgreSQL and libpq-dev packages.
apt: name={{ item.name }} state=latest
apt: name={{ item }} state=latest
with_items:
- { name: 'postgresql' }
- { name: 'libpq-dev' }
- postgresql
- libpq-dev
- name: Install Python connector for PostgreSQL.
pip: name=psycopg2
......
"""
Django settings for webapp project.
Generated by 'django-admin startproject' using Django 1.8.3.
For more information on this file, see
https://docs.djangoproject.com/en/1.8/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.8/ref/settings/
"""
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.8/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '-ay^f7=9e!@jr94v7!v&tl@4zm5=0g8&8d9(a*ffzqywg#@6iy'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = []
# Application definition
INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'backend',
)
MIDDLEWARE_CLASSES = (
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django.middleware.security.SecurityMiddleware',
)
ROOT_URLCONF = 'webapp.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
WSGI_APPLICATION = 'webapp.wsgi.application'
# Database
# https://docs.djangoproject.com/en/1.8/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': '{{ database_name }}',
'USER': '{{ username }}',
'PASSWORD': '{{ database_user_password }}',
'HOST': '127.0.0.1',
'PORT': '5432',
}
}
# Internationalization
# https://docs.djangoproject.com/en/1.8/topics/i18n/
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.8/howto/static-files/
STATIC_URL = '/static/'
......@@ -2,4 +2,4 @@
username: lambda
database_name: lambda_service_db
database_user_password: change_me
repository_download_path: /home/{{ username }}/
repository_download_path: /home/{{ username }}
from django.db import models
class User(models.Model):
id = models.CharField("UUID", primary_key=True, null=False, blank=False, unique=True, default="", max_length=255,
help_text="Unique user id asign by Astakos")
token = models.CharField("Okeanos Token", null=True, blank=True, unique=True, default="", max_length=64,
help_text="Token provided by ~okeanos.")
id = models.CharField("UUID", primary_key=True, null=False, blank=False, unique=True, default="", max_length=255, help_text="Unique user id asign by Astakos")
token = models.CharField("Okeanos Token", null=True, blank=True, unique=True, default="", max_length=64, help_text="Token provided by ~okeanos.")
class Project(models.Model):
id = models.AutoField("Project ID", primary_key=True, null=False, blank=False, unique=True, default="", help_text="Project id provided by kamaki.")
description = models.TextField("Project Description", null=True, blank=True, unique=False, default="",
help_text="The description of a project.")
description = models.TextField("Project Description", null=True, blank=True, unique=False, default="", help_text="The description of a project.")
class Cluster(models.Model):
id = models.AutoField("Cluster ID", primary_key=True, null=False, help_text="Auto-increment cluster id.")
# OneToOneField is a ForeignKey with unique=True. Django recommends using OneToOne Field instead of a ForeignKey
# OneToOneField is a ForeignKey with unique=True. Django recommends using OneToOneField instead of a ForeignKey
# with unique=True.
master_server = models.OneToOneField('Server', null=True, blank=True, on_delete=models.CASCADE)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment