-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2646f47
commit aea0165
Showing
10 changed files
with
140 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
canonical_hostname: kitsvcs.studentrobotics.org | ||
|
||
add_hsts_header: true | ||
certbot_certs: | ||
- domains: | ||
- "{{ canonical_hostname }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Helpdesk System | ||
|
||
App for managing a competition helpdesk. | ||
|
||
This is a deployment of <https://github.com/srobo/helpdesk-system/>. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
-r requirements.txt | ||
|
||
# Latest at the time of writing. Don't actually care about the version, | ||
# only that we pin it for stability. | ||
gunicorn==21.2.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
- name: Restart helpdesk-system | ||
service: | ||
name: helpdesk-system | ||
state: restarted |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
- name: Install virtualenv system dependencies | ||
apt: | ||
pkg: | ||
- python3-virtualenv | ||
- python3-wheel | ||
|
||
- name: Create install directory | ||
file: | ||
path: "{{ install_dir }}" | ||
state: directory | ||
owner: www-data | ||
mode: "755" | ||
|
||
- name: Download | ||
git: | ||
repo: https://github.com/srobo/helpdesk-system | ||
dest: "{{ install_dir }}" | ||
force: true | ||
version: sr2024 # TODO: Pin to commit | ||
notify: | ||
Restart helpdesk-system | ||
register: helpdesk_system_repo | ||
become_user: www-data | ||
|
||
# NOTE: It is expected this configuration won't work as-is | ||
- name: Create configuration if it doesn't exist | ||
copy: | ||
force: false | ||
remote_src: true | ||
src: "{{ install_dir }}/helpdesk/helpdesk/configuration.example.py" | ||
dest: "{{ install_dir }}/helpdesk/helpdesk/configuration.py" | ||
mode: "0600" | ||
owner: www-data | ||
notify: | ||
Restart helpdesk-system | ||
|
||
- name: Install deploy requirements | ||
copy: | ||
src: deploy-requirements.txt | ||
dest: "{{ install_dir }}/deploy-requirements.txt" | ||
mode: "0600" | ||
owner: www-data | ||
notify: | ||
Restart helpdesk-system | ||
register: deploy_requirements | ||
|
||
- name: Install virtual environment | ||
pip: | ||
virtualenv: "{{ venv_dir }}" | ||
requirements: "{{ deploy_requirements.dest }}" | ||
notify: | ||
Restart helpdesk-system | ||
become_user: www-data | ||
when: deploy_requirements.changed or helpdesk_system_repo.changed # noqa: no-handler - Use a handler to ensure execution order | ||
|
||
- name: Install systemd service | ||
template: | ||
src: helpdesk-system.service | ||
dest: /etc/systemd/system/helpdesk-system.service | ||
mode: "0644" | ||
notify: | ||
Restart helpdesk-system | ||
|
||
- name: Install nginx config | ||
template: | ||
src: nginx.conf | ||
dest: /etc/nginx/locations-enabled/helpdesk-system | ||
mode: "0644" | ||
notify: | ||
Reload nginx | ||
|
||
- name: Run migrations # noqa: no-changed-when - We want to always run this (it handles its own idempotency) | ||
django_manage: | ||
command: migrate --noinput -v0 | ||
app_path: "{{ install_dir }}/helpdesk" | ||
virtualenv: "{{ venv_dir }}" | ||
become_user: www-data | ||
when: helpdesk_system_repo.changed # noqa: no-handler - Use a handler to ensure execution order | ||
|
||
- name: Enable service | ||
service: | ||
name: helpdesk-system | ||
state: started | ||
enabled: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
[Unit] | ||
Description=Helpdesk System | ||
After=network.target | ||
|
||
[Service] | ||
User=www-data | ||
|
||
Type=simple | ||
|
||
WorkingDirectory={{ install_dir }}/helpdesk | ||
RuntimeDirectory=helpdesk-system | ||
ExecStart={{ venv_dir }}/bin/gunicorn helpdesk.wsgi:app --bind unix:/var/run/helpdesk-system/helpdesk-system.socket --forwarded-allow-ips='*' | ||
|
||
[Install] | ||
WantedBy=multi-user.target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# HACK: Expects to be run at the root | ||
location / { | ||
proxy_pass http://unix:/var/run/helpdesk-system/helpdesk-system.socket:/; | ||
proxy_pass_request_headers on; | ||
proxy_set_header X-Real-IP $remote_addr; | ||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||
proxy_set_header X-Forwarded-Proto https; | ||
proxy_set_header Host $host; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
install_dir: /srv/helpdesk-system | ||
venv_dir: "{{ install_dir }}/venv" |