services: Add Discord Bot service
This commit is contained in:
parent
732e5e1cd4
commit
6c17cd62eb
5 changed files with 59 additions and 0 deletions
|
@ -5,6 +5,9 @@
|
||||||
- tags: unattended_updates
|
- tags: unattended_updates
|
||||||
import_tasks: unattended-updates.yaml
|
import_tasks: unattended-updates.yaml
|
||||||
|
|
||||||
|
- tags: apt-minimal
|
||||||
|
import_tasks: apt-minimal.yaml
|
||||||
|
|
||||||
- tags: network
|
- tags: network
|
||||||
import_tasks: network.yaml
|
import_tasks: network.yaml
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,12 @@
|
||||||
state: restarted
|
state: restarted
|
||||||
daemon_reload: true
|
daemon_reload: true
|
||||||
|
|
||||||
|
- name: restart discord-bot
|
||||||
|
systemd:
|
||||||
|
name: discord-bot
|
||||||
|
state: restarted
|
||||||
|
daemon_reload: true
|
||||||
|
|
||||||
- name: restart siahsd
|
- name: restart siahsd
|
||||||
systemd:
|
systemd:
|
||||||
name: siahsd
|
name: siahsd
|
||||||
|
|
31
roles/services/tasks/discord_bot.yaml
Normal file
31
roles/services/tasks/discord_bot.yaml
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
---
|
||||||
|
- name: Install dependencies
|
||||||
|
apt:
|
||||||
|
name:
|
||||||
|
- python3-paho-mqtt
|
||||||
|
- python3-tz
|
||||||
|
# Not in apt, install manually: discord.py, discord_webhook
|
||||||
|
|
||||||
|
- name: Clone source
|
||||||
|
git:
|
||||||
|
repo: https://github.com/bitlair/discord-bot.git
|
||||||
|
version: main
|
||||||
|
dest: /var/lib/discord-bot
|
||||||
|
accept_hostkey: yes
|
||||||
|
notify: restart discord-bot
|
||||||
|
|
||||||
|
- name: Install service file
|
||||||
|
template:
|
||||||
|
src: discord-bot.service
|
||||||
|
dest: /etc/systemd/system/discord-bot.service
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: 0644
|
||||||
|
notify: restart discord-bot
|
||||||
|
|
||||||
|
- name: Start discord-bot
|
||||||
|
systemd:
|
||||||
|
name: discord-bot
|
||||||
|
state: started
|
||||||
|
enabled: yes
|
||||||
|
daemon_reload: true
|
|
@ -2,6 +2,9 @@
|
||||||
- tags: services_ircbot
|
- tags: services_ircbot
|
||||||
import_tasks: ircbot.yaml
|
import_tasks: ircbot.yaml
|
||||||
|
|
||||||
|
- tags: services_discord_bot
|
||||||
|
import_tasks: discord_bot.yaml
|
||||||
|
|
||||||
- tags: services_flipdot
|
- tags: services_flipdot
|
||||||
import_tasks: flipdot.yaml
|
import_tasks: flipdot.yaml
|
||||||
|
|
||||||
|
|
16
roles/services/templates/discord-bot.service
Normal file
16
roles/services/templates/discord-bot.service
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
# Managed by Ansible
|
||||||
|
|
||||||
|
[Unit]
|
||||||
|
Description=HobbyBot
|
||||||
|
After=network.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=simple
|
||||||
|
Restart=on-failure
|
||||||
|
RestartSec=10s
|
||||||
|
ExecStart=/var/lib/discord-bot/main.py
|
||||||
|
DynamicUser=true
|
||||||
|
Environment="DISCORD_TOKEN={{ discord_token }}"
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
Loading…
Add table
Reference in a new issue