From 8caa19249791e15dfb9d458135542069b3265284 Mon Sep 17 00:00:00 2001
From: Morten Linderud <morten@linderud.pw>
Date: Wed, 17 Jun 2020 22:50:19 +0200
Subject: [PATCH] Added bugbot role

Signed-off-by: Morten Linderud <morten@linderud.pw>
---
 roles/bugbot/defaults/main.yml    |  8 ++++++++
 roles/bugbot/files/bugbot.service | 12 ++++++++++++
 roles/bugbot/handlers/main.yml    |  4 ++++
 roles/bugbot/tasks/main.yml       | 20 ++++++++++++++++++++
 4 files changed, 44 insertions(+)
 create mode 100644 roles/bugbot/defaults/main.yml
 create mode 100644 roles/bugbot/files/bugbot.service
 create mode 100644 roles/bugbot/handlers/main.yml
 create mode 100644 roles/bugbot/tasks/main.yml

diff --git a/roles/bugbot/defaults/main.yml b/roles/bugbot/defaults/main.yml
new file mode 100644
index 000000000..d01e8c569
--- /dev/null
+++ b/roles/bugbot/defaults/main.yml
@@ -0,0 +1,8 @@
+---
+irc_host: 'chat.freenode.net'
+irc_port: '6697'
+irc_channel: '#archlinux-bugs'
+bugbot_admins:
+  - keenerd
+  - falconindy
+  - Foxboron
diff --git a/roles/bugbot/files/bugbot.service b/roles/bugbot/files/bugbot.service
new file mode 100644
index 000000000..1170655f4
--- /dev/null
+++ b/roles/bugbot/files/bugbot.service
@@ -0,0 +1,12 @@
+[Unit]
+Description=The official Arch Linux IRC bugbot
+
+[Service]
+EnvironmentFile=/srv/bugbot/env
+ExecStart=/srv/bugbot/bugbot.py
+Restart=on-failure
+ProtectSystem=full
+DynamicUser=yes
+
+[Install]
+WantedBy=default.target
diff --git a/roles/bugbot/handlers/main.yml b/roles/bugbot/handlers/main.yml
new file mode 100644
index 000000000..f9ee66365
--- /dev/null
+++ b/roles/bugbot/handlers/main.yml
@@ -0,0 +1,4 @@
+---
+
+- name: daemon reload
+  command: systemctl daemon-reload
diff --git a/roles/bugbot/tasks/main.yml b/roles/bugbot/tasks/main.yml
new file mode 100644
index 000000000..c415d42b7
--- /dev/null
+++ b/roles/bugbot/tasks/main.yml
@@ -0,0 +1,20 @@
+---
+
+- name: install bugbot utilities
+  pacman: name=python-irc,python-beautifulsoup4,python-lxml state=present
+
+- name: clone bugbot source
+  git:
+    repo: https://gitlab.archlinux.org/archlinux/bugbot.git
+    dest: /srv/bugbot
+
+- name: install env file
+  template: src=bugbot.j2 dest=/srv/bugbot/env owner=root group=root mode=0600
+
+- name: install bugbot systemd service
+  copy: src=bugbot.service dest=/etc/systemd/system/bugbot.service
+  notify:
+    - daemon reload
+
+- name: start and enable bugbot service
+  service: name="bugbot.service" enabled=yes state=started
-- 
GitLab