Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add hosting of the Discord Logs Uploader bot #61

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions playbook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@
- competitor-services-nginx
- code-submitter
- discord-gated-entry
- discord-logs-uploader
5 changes: 5 additions & 0 deletions roles/discord-logs-uploader/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Discord Gated Entry

A Bot for gating entry to a Discord server.

This is a deployment of <https://github.com/WillB97/discord-logs-uploader>.
4 changes: 4 additions & 0 deletions roles/discord-logs-uploader/handlers/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- name: Restart discord-logs-uploader
service:
name: discord-logs-uploader
state: restarted
63 changes: 63 additions & 0 deletions roles/discord-logs-uploader/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
- name: Install virtualenv system dependencies
apt:
pkg:
- python3-virtualenv
- python3-wheel

- name: Create user
user:
name: discord-logs-uploader
shell: /bin/nologin
state: present
create_home: false

- name: Create install directory
file:
path: "{{ install_dir }}"
state: directory
owner: discord-logs-uploader
mode: "755"

- name: Download
git:
repo: https://github.com/WillB97/discord-logs-uploader
dest: "{{ install_dir }}"
force: true
version: 87002f6472e284d6bd446fadb679d33fca102761
notify:
Restart discord-logs-uploader
register: discord_gated_entry_repo
become_user: discord-logs-uploader

- name: Bootstrap environment file
copy:
content: ""
dest: "{{ install_dir }}/.env"
force: false
mode: "0600"
owner: discord-logs-uploader
notify:
Restart discord-logs-uploader

- name: Install virtual environment
pip:
virtualenv: "{{ venv_dir }}"
requirements: "{{ install_dir }}/requirements.txt"
notify:
Restart discord-logs-uploader
become_user: discord-logs-uploader
when: discord_gated_entry_repo.changed # noqa: no-handler - Use a handler to ensure execution order

- name: Install systemd service
template:
src: discord-logs-uploader.service
dest: /etc/systemd/system/discord-logs-uploader.service
mode: "0644"
notify:
Restart discord-logs-uploader

- name: Enable service
service:
name: discord-logs-uploader
state: started
enabled: true
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[Unit]
Description=Discord bot for sending logs to teams via their Discord channels
After=network.target

[Service]
User=discord-logs-uploader

Type=simple

WorkingDirectory={{ install_dir }}
RuntimeDirectory=discord-logs-uploader

ExecStart=/srv/discord-logs-uploader/venv/bin/python discord_logs_uploader.py

[Install]
WantedBy=multi-user.target
2 changes: 2 additions & 0 deletions roles/discord-logs-uploader/vars/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
install_dir: /srv/discord-logs-uploader
venv_dir: "{{ install_dir }}/venv"
Loading