Skip to content
Snippets Groups Projects
Commit d0a73a3d authored by Maxime Bombar's avatar Maxime Bombar
Browse files

Add role to manage thunes.

parent 7bf50300
No related merge requests found
thunes_debug: True
thunes_db_name: "thunes_dev"
thunes_db_user: "thunes_dev"
thunes_db_ip: "172.16.0.2"
thunes_db_password: "l0gHdg8AhZOtg"
thunes_debug: False
thunes_db_name: "thunes"
thunes_db_user: "thunes"
thunes_db_ip: "172.16.0.2"
thunes_password_db: "TFacRAvx3FHcM"
---
- name: Reload nginx
systemd:
name: nginx
state: reloaded
- name: Reload uwsgi
systemd:
name: uwsgi
state: reloaded
---
- name: Install dependencies
apt:
update_cache: true
install_recommends: false
name:
- python3-venv
- nginx
- uwsgi
- uwsgi-plugin-python3
register: apt_result
retries: 3
until: apt_result is succeeded
- name: Create thunes directory
file:
path: /var/www/MathoosHouse
state: directory
mode: "2775"
owner: www-data
- name: Clone Thunes repository
git:
repo: https://gitea.servens.org/bombar/MathoosHouse.git
dest: /var/www/MathoosHouse
track_submodules: yes
version: master
umask: "002"
when: not ansible_check_mode
- name: Generate django SECRET_KEY
shell: python3 -c 'import random; print("".join([random.choice("abcdefghijklmnopqrstuvwxyz0123456789!@#$%&*(-_=+)") for i in range(50)]))'
register: django_secret_key
check_mode: false
changed_when: true
- name: Deploy settings_local
template:
src: settings_local.j2
dest: /var/www/MathoosHouse/MathoosHouse/settings_local.py
notify: Reload uwsgi
- name: Install pip requirements
pip:
requirements: /var/www/MathoosHouse/requirements.txt
virtualenv: /var/www/MathoosHouse/.env
virtualenv_command: pyvenv
umask: "0002"
- name: Install migrations
django_manage:
app_path: /var/www/MathoosHouse
command: migrate
virtualenv: /var/www/MathoosHouse/.env
- name: Configure nginx
file:
src: /var/www/MathoosHouse/WebUtils/MathoosHouse.nginx
dest: /etc/nginx/sites-enabled/MathoosHouse.nginx
state: link
when: not ansible_check_mode
notify: Reload nginx
- name: Remove default nginx config
file:
path: /etc/nginx/sites-enabled/default
state: absent
when: not ansible_check_mode
notify: Reload nginx
- name: Configure uwsgi
file:
src: /var/www/MathoosHouse/WebUtils/MathoosHouse.uwsgi
dest: /etc/uwsgi/apps-enabled/MathoosHouse.ini
state: link
when: not ansible_check_mode
notify: Reload uwsgi
{{ ansible_managed | comment }}
SECRET_KEY = "{{ django_secret_key.stdout_lines | first }}"
DEBUG = {{ thunes_debug }}
INTERNAL_IPS = []
EMAIL_HOST = ''
SERVER_EMAIL = ''
DEFAULT_FROM_EMAIL = ''
EMAIL_PORT = 25
OPTIONAL_APPS = []
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': '{{ thunes_db_name }}',
'USER': '{{ thunes_db_user }}',
'PASSWORD': '{{ thunes_db_password }}',
'HOST': '{{ thunes_db_ip }}',
'PORT': '5432',
}
}
#!/usr/bin/env ansible-playbook
---
- hosts: thunes thunes-dev
roles:
- thunes
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment