https://github.com/ansibleguy/infra_django_apache
Ansible Role to provision Django sites
https://github.com/ansibleguy/infra_django_apache
ansible ansible-role automation django iac infrastructure-as-code mariadb postgresql python3 webserver
Last synced: 10 months ago
JSON representation
Ansible Role to provision Django sites
- Host: GitHub
- URL: https://github.com/ansibleguy/infra_django_apache
- Owner: ansibleguy
- License: other
- Created: 2021-11-02T21:05:26.000Z (over 4 years ago)
- Default Branch: latest
- Last Pushed: 2024-08-05T19:54:07.000Z (almost 2 years ago)
- Last Synced: 2024-08-05T23:08:03.352Z (almost 2 years ago)
- Topics: ansible, ansible-role, automation, django, iac, infrastructure-as-code, mariadb, postgresql, python3, webserver
- Language: Jinja
- Homepage:
- Size: 88.9 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE.txt
Awesome Lists containing this project
README
# Ansible Role - Python3 Django
Ansible Role to deploy one or multiple Django applications on a linux server using Apache2 as webserver.
[](https://github.com/ansibleguy/infra_django_apache/actions/workflows/lint.yml)
[](https://galaxy.ansible.com/ui/standalone/roles/ansibleguy/infra_django_apache)
**Molecule Integration-Tests**:
* Status: [](https://github.com/ansibleguy/_meta_cicd/blob/latest/templates/usr/local/bin/cicd/molecule.sh.j2) |
[](https://github.com/ansibleguy/infra_django_apache/actions/workflows/integration_test_result.yml)
* Logs: [API](https://ci.ansibleguy.net/api/job/ansible-test-molecule-infra_django_apache/logs?token=2b7bba30-9a37-4b57-be8a-99e23016ce70&lines=1000) | [Short](https://badges.ansibleguy.net/log/molecule_infra_django_apache_test_short.log) | [Full](https://badges.ansibleguy.net/log/molecule_infra_django_apache_test.log)
Internal CI: [Tester Role](https://github.com/ansibleguy/_meta_cicd) | [Jobs API](https://github.com/O-X-L/github-self-hosted-jobs-systemd)
**Tested:**
* Debian 11
* Debian 12
----
## Install
```bash
# latest
ansible-galaxy role install git+https://github.com/ansibleguy/infra_django_apache
# from galaxy
ansible-galaxy install ansibleguy.infra_django_apache
# or to custom role-path
ansible-galaxy install ansibleguy.infra_django_apache --roles-path ./roles
# install dependencies
ansible-galaxy install -r requirements.yml
```
----
## Advertisement
* Need **professional support** using Ansible or managing Web-Applications? Contact us:
E-Mail: [contact@oxl.at](mailto:contact@oxl.at)
Tel: [+43 3115 40 900 0](tel:+433115409000)
Web: [EN](https://www.o-x-l.com) | [DE](https://www.oxl.at)
Language: German or English
* You want a simple **Ansible GUI**?
Check-out this [Ansible WebUI](https://github.com/ansibleguy/webui)
----
## Usage
### Config
You need to define your instances by configuring the 'mariadb' dictionary!
```yaml
django:
sites:
niceApp:
domain: 'django.ansibleguy.net'
project: 'super' # the directory containing the 'settings.py' is named like this
sync_code: # sync's local code to the remote server
enabled: true
src: '/home/ansibleguy/code/niceApp'
static_src: '/home/ansibleguy/code/niceApp_static'
venv: '/var/lib/niceApp'
python_modules:
present: ['netaddr', 'pycryptodome']
env_pythonpath: ['/var/lib/myOtherApp'] # will get added to django's PYTHONPATH environmental variable
ssl:
mode: 'letsencrypt'
letsencrypt:
email: 'django@template.ansibleguy.net'
```
You might want to use 'ansible-vault' to encrypt your passwords:
```bash
ansible-vault encrypt_string
```
### Execution
Run the playbook/role:
```bash
ansible-playbook -K -D -i inventory/hosts.yml django.yml --ask-vault-pass
```
There are also some useful **tags** available:
* base => only configure basics; instances will not be touched
* sites
* config
* db
* sync => only sync local code to remote host (_if enabled by user_)
* django => don't start sub-roles for apache and/or mariadb
To debug errors - you can set the 'debug' variable at runtime:
```bash
ansible-playbook -K -D -i inventory/hosts.yml playbook.yml -e debug=yes
```
----
## Functionality
* **Package installation**
* Ansible dependencies (_minimal_)
* **Configuration**
* Apache using [THIS](https://github.com/ansibleguy/infra_apache) role
* Support for MySQL or PostgreSQL
* **Default opt-in**:
* MariaDB database using [THIS](https://github.com/ansibleguy/infra_mariadb) role
* **Default opt-outs**:
* Database backup service
* Special apache config => can be passed using the 'django' dictionary
* Running 'collectstatic'
* **Default config**:
* A Self-Signed certificate will be used
* Database type => MariaDB
* Database will be installed automatically
* Using a python virtual environment
* A database migration script will be created in the venv directory
----
## Info
* **Note:** this role currently only supports debian-based systems
* **Note:** Most of the role's functionality can be opted in or out.
For all available options - see the default-config located in the main/site defaults-file!
* **Warning:** Not every setting/variable you provide will be checked for validity. Bad config might break the role!