This repository is my homework for the university lecture "194.030 Configuration Management" at TU Wien.
This is a proof of concept for "elektrify" Django.
This Django Project uses libelektra for storing it's settings.
An elektra-specification for the most important Django settings can be found in spec/django.spec.ni:
ALLOWED_HOSTSCSRF_TRUSTED_ORIGINSDATABASE:Dict- Key-Value-Pair.
- Value is another
Dict:ENGINENAMEUSERPASSWORDHOSTPORT
DEBUGINSTALLED_APPS
Django's license can be found here.
Specification for Django's settings can be found here.
Since this is a very generic python project, installation is very easy:
-
Checkout source code
git clone ...
-
Create a new virtual environment named
venvwith system site packages:python3 -m venv venv --system-site-packages
-
Install requirements:
./venv/bin/pip install -r requirements.txt
-
Mount specification and apply test data:
./spec/test-spec.sh
-
initialize db and apply migrations:
./venv/bin/python3 manage.py migrate
-
Run server:
./venv/bin/python3 manage.py runserver
Open http://127.0.0.1:8000 in your browser for the hello world page, or http://127.0.0.1:8000/admin for the admin console.
If you want to access django admin, you have to create a superuser first: python manage.py createsuperuser.
You'll find my contact data in the private cm2022s repository.
-
Install ansible:
pip3 install ansible
-
Run playbook:
ansible-playbook philippleeb/setup-playbook.yml --ask-become-pass
-
Move to the directory:
cd ~/django-libelektra
-
Run application:
./venv/bin/python3 manage.py runserver
Is guaranteed by ansible for all inbuilt functions and the scripts also only use idempotent functions (for example: KDB set). The mount is checked in the playbook as well so that the mount setup is only done if it does not exist.
This is by default done by ansible inbuilt functions. The same conzept is implemented with the "check kdb mounts", where the mounts are only executed, if they do not exist.
The titles of the tasks should give a brief idea what is done by them.
This is guaranteed by the kdb commands which are used in the shell-script.
Ansible handles errors by stopping the specified chain, if there are critical failures. In the case of mounts, the "check kdb mounts" task prevents errors in the "mount and configure" task.
- Wrong python version which was not compatible with the setup (3.10) -> Downgrade to python 3.9