ansible/roles/services/tasks/discord_bot.yaml

44 lines
1,002 B
YAML

---
- name: Install dependencies
ansible.builtin.apt:
name:
- python3-paho-mqtt
- python3-tz
- virtualenv
- name: Create virtualenv
ansible.builtin.command:
cmd: virtualenv /opt/miflora_exporter/.venv
args:
creates: /var/lib/discord-bot/.venv
- name: Install Python dependencies
ansible.builtin.shell:
cmd: . .venv/bin/activate && pip install -r requirements.txt
args:
chdir: /var/lib/discord-bot
- name: Clone source
ansible.builtin.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
ansible.builtin.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
ansible.builtin.systemd:
name: discord-bot
state: started
enabled: true
daemon_reload: true