Skip to content
Snippets Groups Projects
Commit 9016d78f authored by Lars Beckers's avatar Lars Beckers Committed by Hinrikus Wolf
Browse files

uwsgi-python: add (old) wahlsystem

parent 7ac8dbb9
No related branches found
No related tags found
1 merge request!3Unify uwsgi python
This commit is part of merge request !3. Comments created here will be created in the context of that merge request.
...@@ -33,6 +33,14 @@ ...@@ -33,6 +33,14 @@
service: name="protokollsystem-celery" state=restarted service: name="protokollsystem-celery" state=restarted
listen: "restart uwsgi instance protokollsystem" listen: "restart uwsgi instance protokollsystem"
- name: restart uwsgi instance wahlsystem uwsgi
service: name="uwsgi@wahlsystem" state=restarted
listen: "restart uwsgi instance wahlsystem"
- name: restart uwsgi instance wahlsystem celery
service: name="wahlsystem-celery" state=restarted
listen: "restart uwsgi instance wahlsystem"
- name: restart uwsgi instance meckerkasten - name: restart uwsgi instance meckerkasten
service: name="uwsgi@meckerkasten" state=restarted service: name="uwsgi@meckerkasten" state=restarted
......
---
- name: ensure we have the blogfiles folder
file:
name: "{{ app_path }}/blogfiles"
state: directory
owner: "{{ app_user }}"
group: "{{ app_group }}"
mode: 0755
tags:
- wahlsystem
- webservices
- name: ensure the celery unit file exists
template:
src: apps/wahlsystem-celery.service.j2
dest: "/etc/systemd/system/{{ app_name }}-celery.service"
owner: root
group: root
mode: 0644
notify:
- reload systemd service files
- "restart uwsgi instance {{app.instance}}"
- name: ensure the celery service is enabled
service:
name: "{{app_name}}-celery"
enabled: yes
state: started
[Unit]
Description={{ app_name }}-Celery
After=network.target
[Service]
User={{ app_user }}
Group={{ app_group }}
WorkingDirectory={{ app_path }}
Environment=VIRTUAL_ENV="{{ app_path }}"
ExecStart={{ app_path }}/bin/celery -A server.celery worker --loglevel=DEBUG --concurrency={{ wahl_celery_concurrency }}
Restart=always
[Install]
WantedBy=multi-user.target
SQLALCHEMY_DATABASE_URI = "postgresql://{{ wahl_user }}:@/{{ wahl_name }}" from secret_config import secret_key as SECRET_KEY
SQLALCHEMY_DATABASE_URI = "postgresql://{{ app_user }}:@/{{ app_name }}"
SQLALCHEMY_TRACK_MODIFICATIONS = False SQLALCHEMY_TRACK_MODIFICATIONS = False
SECRET_KEY = "{{ wahl_secret }}"
DEBUG = False DEBUG = False
MAIL_ACTIVE = {{ wahl_mail }} MAIL_ACTIVE = {{ wahl_mail }}
MAIL_FROM = "{{ wahl_mail_from }}" MAIL_FROM = "{{ wahl_mail_from }}"
......
--- app_name: wahlsystem
# file: wahlsystem/defaults/main.yml app_user: wahl
app_group: wahl
app_home: /var/www/wahlsystem
app_path: /var/www/wahlsystem/program
app_python_version: 3
app_mules: 0
app_enable_threads: false
app_harakiri: 30
app_uwsgi_options: []
app_venv: /var/www/wahlsystem/program/
app_program: server.py
app_callable: app
app_command: "runserver"
app_mountpoint: /
app_service_env: []
wahl_web_root: /var/www/wahlsystem app_db_name: wahlsystem
wahl_name: wahlsystem app_db_type: postgres
wahl_user: wahl
wahl_group: wahl app_additional_software:
- "fontconfig"
- "tex-gyre"
app_deploy_key: "{{ inventory_dir }}/files/deploy-keys/wahlsystem"
app_git_url: "git@git.fsmpi.rwth-aachen.de:wahl/wahlsys.git"
app_git_version: HEAD
app_requirements_file: requirements.txt
app_config_file: config.py
app_secret_config: true
app_secret_config_keys: []
wahl_celery_broker: 'redis://localhost:6379/0'
wahl_celery_concurrency: 1 wahl_celery_concurrency: 1
wahl_ldap_cert: '' wahl_ldap_cert: ''
wahl_secret: ''
wahl_mail: True wahl_mail: True
wahl_mail_from: 'wahl@example.com' wahl_mail_from: 'wahl@example.com'
wahl_mail_host: 'mail.example.com:25' wahl_mail_host: 'mail.example.com:25'
...@@ -15,7 +42,6 @@ wahl_mail_user: '' ...@@ -15,7 +42,6 @@ wahl_mail_user: ''
wahl_mail_password: '' wahl_mail_password: ''
wahl_mail_tls: False wahl_mail_tls: False
wahl_mail_prefix: 'Wahlsystem' wahl_mail_prefix: 'Wahlsystem'
wahl_celery_broker: 'redis://localhost:6379/0'
wahl_server_name: 'wahl.example.com' wahl_server_name: 'wahl.example.com'
wahl_url_root: 'wahl.example.com' wahl_url_root: 'wahl.example.com'
wahl_url_proto: 'https' wahl_url_proto: 'https'
...@@ -24,4 +50,3 @@ wahl_mailman_api_url: 'https://lists.example.com/mailmanAPI' ...@@ -24,4 +50,3 @@ wahl_mailman_api_url: 'https://lists.example.com/mailmanAPI'
wahl_mailman_api_key: '' wahl_mailman_api_key: ''
wahl_mailman_default_newpw: '' wahl_mailman_default_newpw: ''
wahl_mailman_host: 'lists.example.com' wahl_mailman_host: 'lists.example.com'
---
# file: wahlsystem/handlers/main.yml
- name: reload systemd service files
command: systemctl daemon-reload
- name: restart uwsgi for wahlsystem
service:
name: "{{ item }}"
state: restarted
with_items:
- "{{ wahl_name }}"
- "{{ wahl_name }}-celery"
- name: create tmpfiles
command: systemd-tmpfiles --create
---
# file: wahlsystem/meta/main.yml
dependencies:
- { role: texlive }
- { role: cups-client }
- { role: uwsgi-python, uwsgi_name: "{{wahl_name}}", uwsgi_user: "{{wahl_user}}", uwsgi_group: "{{wahl_group}}", uwsgi_path: "{{wahl_web_root}}/program", uwsgi_home: "{{wahl_web_root}}", uwsgi_program: "server.py", uwsgi_callable: "app", uwsgi_command: "runserver", uwsgi_db: "postgres", uwsgi_python: 3, uwsgi_mules: 0, uwsgi_harakiri: 30 }
---
# file: wahlsystem/tasks/main.yml
- name: ensure we have the required software and fonts
apt:
name: "{{ item }}"
state: present
with_items:
- fontconfig
- tex-gyre
- virtualenv
tags:
- wahlsystem
- webservices
- name: ensure the deploy key is available
copy:
src: "{{ wahl_deploy_key }}"
dest: /root/.ssh/wahlsystem
owner: root
group: root
mode: 0600
tags:
- wahlsystem
- webservices
# https://github.com/ansible/ansible/issues/27699
- name: ensure fucking git module is able to clone
command: mount -o remount,exec /tmp
tags:
- wahlsystem
- webservices
- name: ensure the git is at the current revision
git:
repo: git@git.fsmpi.rwth-aachen.de:wahl/wahlsys.git
dest: "{{ wahl_web_root }}/program"
key_file: /root/.ssh/wahlsystem
version: HEAD
notify:
- restart uwsgi for wahlsystem
tags:
- wahlsystem
- webservices
- name: ensure fucking git module is not able to clone anymore
command: mount -o remount,noexec /tmp
tags:
- wahlsystem
- webservices
- name: ensure we have a virtualenv
pip:
requirements: "{{ wahl_web_root }}/program/requirements.txt"
virtualenv: "{{ wahl_web_root }}/program"
virtualenv_python: python3
notify:
- restart uwsgi for wahlsystem
tags:
- wahlsystem
- webservices
- name: ensure we have the necessary folder
file:
name: "{{ wahl_web_root }}/program/blogfiles"
state: directory
owner: "{{ wahl_user }}"
group: "{{ wahl_group }}"
mode: 0755
tags:
- wahlsystem
- webservices
- name: ensure we have our config
template:
src: config.py.j2
dest: "{{ wahl_web_root }}/program/config.py"
owner: "{{ wahl_user }}"
group: "{{ wahl_group }}"
mode: 0644
notify:
- restart uwsgi for wahlsystem
tags:
- wahlsystem
- webservices
- name: ensure the unit file exists
template:
src: wahlsystem.service.j2
dest: "/etc/systemd/system/{{ wahl_name }}.service"
owner: root
group: root
mode: 0644
notify:
- reload systemd service files
- restart uwsgi for wahlsystem
tags:
- wahlsystem
- webservices
- name: ensure the celery unit file exists
template:
src: celery.service.j2
dest: "/etc/systemd/system/{{ wahl_name }}-celery.service"
owner: root
group: root
mode: 0644
notify:
- reload systemd service files
- restart uwsgi for wahlsystem
tags:
- wahlsystem
- webservices
- meta: flush_handlers
- name: ensure the services are enabled
service:
name: "{{ item }}"
enabled: yes
state: started
with_items:
- "{{ wahl_name }}"
- "{{ wahl_name }}-celery"
tags:
- wahlsystem
- webservices
[Unit]
Description=Wahlsystem-Celery
After=network.target
[Service]
User={{ wahl_user }}
Group={{ wahl_group }}
WorkingDirectory={{ wahl_web_root }}/program
Environment=VIRTUAL_ENV="{{ wahl_web_root }}/program"
ExecStart={{ wahl_web_root }}/program/bin/celery -A server.celery worker --loglevel=DEBUG --concurrency={{ wahl_celery_concurrency }}
Restart=always
[Install]
WantedBy=multi-user.target
[Unit]
Description=Wahlsystem
After=network.target
Wants=wahlsystem-celery.service
[Service]
{% if wahl_ldap_cert %}
Environment=LDAPTLS_CACERT={{ wahl_ldap_cert }}
{% endif %}
ExecStart=/usr/bin/uwsgi --ini /etc/uwsgi/apps-available/{{ wahl_name }}.ini
Restart=always
KillSignal=SIGQUIT
Type=notify
NotifyAccess=all
[Install]
WantedBy=multi-user.target
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment