-
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
Showing
6 changed files
with
91 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 |
---|---|---|
|
@@ -20,3 +20,4 @@ | |
roles: | ||
- competitor-services-nginx | ||
- code-submitter | ||
- discord-gated-entry |
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 @@ | ||
# Discord Gated Entry | ||
|
||
A Bot for gating entry to a Discord server. | ||
|
||
This is a deployment of <https://github.com/srobo/discord-gated-entry>. |
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 discord-gated-entry | ||
service: | ||
name: discord-gated-entry | ||
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,63 @@ | ||
- name: Install virtualenv system dependencies | ||
apt: | ||
pkg: | ||
- python3-virtualenv | ||
- python3-wheel | ||
|
||
- name: Create user | ||
user: | ||
name: discord | ||
shell: /bin/nologin | ||
state: present | ||
create_home: false | ||
|
||
- name: Create install directory | ||
file: | ||
path: "{{ install_dir }}" | ||
state: directory | ||
owner: discord | ||
mode: "755" | ||
|
||
- name: Download | ||
git: | ||
repo: https://github.com/srobo/discord-gated-entry | ||
dest: "{{ install_dir }}" | ||
force: true | ||
version: 476a9c942f580e2950048c2b95e15429cb0ae33d | ||
notify: | ||
Restart discord-gated-entry | ||
register: discord_gated_entry_repo | ||
become_user: discord | ||
|
||
- name: Bootstrap environment file | ||
copy: | ||
content: "" | ||
dest: "{{ install_dir }}/.env" | ||
force: false | ||
mode: "0600" | ||
owner: discord | ||
notify: | ||
Restart discord-gated-entry | ||
|
||
- name: Install virtual environment | ||
pip: | ||
virtualenv: "{{ venv_dir }}" | ||
requirements: "{{ install_dir }}/requirements.txt" | ||
notify: | ||
Restart discord-gated-entry | ||
become_user: discord | ||
when: discord_gated_entry_repo.changed # noqa: no-handler - Use a handler to ensure execution order | ||
|
||
- name: Install systemd service | ||
template: | ||
src: discord-gated-entry.service | ||
dest: /etc/systemd/system/discord-gated-entry.service | ||
mode: "0644" | ||
notify: | ||
Restart discord-gated-entry | ||
|
||
- name: Enable service | ||
service: | ||
name: discord-gated-entry | ||
state: started | ||
enabled: true |
16 changes: 16 additions & 0 deletions
16
roles/discord-gated-entry/templates/discord-gated-entry.service
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,16 @@ | ||
[Unit] | ||
Description=Discord bot for gated entry | ||
After=network.target | ||
|
||
[Service] | ||
User=discord | ||
|
||
Type=simple | ||
|
||
WorkingDirectory={{ install_dir }} | ||
RuntimeDirectory=discord-gated-entry | ||
|
||
ExecStart=/srv/discord-gated-entry/venv/bin/python main.py | ||
|
||
[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,2 @@ | ||
install_dir: /srv/discord-gated-entry | ||
venv_dir: "{{ install_dir }}/venv" |