Commit 80cc7d8a authored by Georgios Ouzounis's avatar Georgios Ouzounis

LAM-53 Added Apache server to host Django webapp.

parent 2cfb10e6
......@@ -13,3 +13,6 @@
- name: migrate_backend_app
django_manage: command=migrate app_path={{ repository_download_path }}/okeanos-LoD/webapp/ apps=backend
- name: restart_apache2
service: name=apache2 state=restarted
---
- name: Install apache2, apache2-dev and libapache2-mod-wsgi packages.
apt: name={{ item }} state=latest
with_items:
- apache2
- apache2-dev
- libapache2-mod-wsgi
- name: Get the hostname of the vm.
command: hostname
register: hostname
- name: Copy Lambda sites-available configuration.
template: src=lambda-service-backend.conf.j2 dest=/etc/apache2/sites-available/lambda-service-backend.conf
- name: Add lambda-service-backend to sites-enabled.
file: src=/etc/apache2/sites-available/lambda-service-backend.conf dest=/etc/apache2/sites-enabled/lambda-service-backend.conf state=link
- name: Remove default sites-enabled.
file: name=/etc/apache2/sites-enabled/000-default.conf state=absent
- name: Configure Apache.
lineinfile: dest=/etc/apache2/apache2.conf line="WSGIPythonPath {{ repository_download_path }}/okeanos-LoD/webapp" state=present insertafter=EOF
notify:
- restart_apache2
......@@ -13,8 +13,8 @@
- sudo
- git
- name: Create service user.
user: name={{ username }} shell=/bin/bash
- name: Include apache2 tasks.
include: apache-install.yml
- name: Include postgresql-install tasks.
include: postgresql-install.yml
......@@ -27,7 +27,7 @@
# The repository should be changed when the pull request gets merged.
- name: Change repository permissions.
file: path={{ repository_download_path }} owner={{ username }} recurse=yes
file: path={{ repository_download_path }} owner=root group=root recurse=yes
- name: Setup Django database configuration.
template: src=settings.py.j2 dest={{ repository_download_path}}/okeanos-LoD/webapp/webapp/settings.py
......
......@@ -14,4 +14,4 @@
- name: Create PostgreSQL role for lambdaservice user.
sudo_user: postgres
postgresql_user: db={{ database_name }} name={{ username }} password={{ database_user_password }}
postgresql_user: db={{ database_name }} name={{ database_username }} password={{ database_user_password }}
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com
ServerName {{ hostname.stdout_lines | replace("[", "") | replace("u", "") | replace("'", "") | replace("]", "") }}.vm.okeanos.grnet.gr
#ServerAdmin webmaster@localhost
DocumentRoot {{ repository_download_path }}/okeanos-LoD/webapp/
WSGIScriptAlias / {{ repository_download_path }}/okeanos-LoD/webapp/webapp/wsgi.py
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
......@@ -79,7 +79,7 @@ DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': '{{ database_name }}',
'USER': '{{ username }}',
'USER': '{{ database_username }}',
'PASSWORD': '{{ database_user_password }}',
'HOST': '127.0.0.1',
'PORT': '5432',
......
---
username: lambda
database_name: lambda_service_db
database_username: lambda
database_name: lambda_db
database_user_password: change_me
repository_download_path: /home/{{ username }}
repository_download_path: /var/www
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