From cf8a96f8d991af4ea8a8c5708e0660d4b6667040 Mon Sep 17 00:00:00 2001
From: ale <ale@incal.net>
Date: Sat, 16 May 2020 08:24:48 +0100
Subject: [PATCH] Add hark (a canary tcp listener)

---
 playbooks/common.yml                 |  5 +++++
 roles/hark/defaults/main.yml         | 15 +++++++++++++++
 roles/hark/handlers/main.yml         |  7 +++++++
 roles/hark/tasks/main.yml            | 13 +++++++++++++
 roles/hark/templates/hark.default.j2 |  2 ++
 services.common.yml                  | 21 +++++++++++++++++++++
 6 files changed, 63 insertions(+)
 create mode 100644 roles/hark/defaults/main.yml
 create mode 100644 roles/hark/handlers/main.yml
 create mode 100644 roles/hark/tasks/main.yml
 create mode 100644 roles/hark/templates/hark.default.j2

diff --git a/playbooks/common.yml b/playbooks/common.yml
index ae7bd7c8..d13eb4d0 100644
--- a/playbooks/common.yml
+++ b/playbooks/common.yml
@@ -51,3 +51,8 @@
 - hosts: data-exchange
   roles:
     - data-exchange
+
+- hosts: hark
+  roles:
+    - hark
+
diff --git a/roles/hark/defaults/main.yml b/roles/hark/defaults/main.yml
new file mode 100644
index 00000000..f43268de
--- /dev/null
+++ b/roles/hark/defaults/main.yml
@@ -0,0 +1,15 @@
+---
+
+# Keep services.common.yml in sync with this variable.
+hark_ports:
+  - 23
+  - 79
+  - 88
+  - 111
+  - 161
+  - 631
+  - 1080
+  - 6000
+  - 8000
+  - 8080
+
diff --git a/roles/hark/handlers/main.yml b/roles/hark/handlers/main.yml
new file mode 100644
index 00000000..2a7e60fd
--- /dev/null
+++ b/roles/hark/handlers/main.yml
@@ -0,0 +1,7 @@
+---
+
+- listen: restart hark
+  systemd:
+    name: hark.service
+    state: restarted
+
diff --git a/roles/hark/tasks/main.yml b/roles/hark/tasks/main.yml
new file mode 100644
index 00000000..f85f25be
--- /dev/null
+++ b/roles/hark/tasks/main.yml
@@ -0,0 +1,13 @@
+---
+
+- name: Install hark package
+  apt:
+    name: hark
+    state: present
+
+- name: Configure har
+  template:
+    src: hark.default.j2
+    dest: "/etc/default/hark"
+  notify: restart hark
+
diff --git a/roles/hark/templates/hark.default.j2 b/roles/hark/templates/hark.default.j2
new file mode 100644
index 00000000..9c1d3026
--- /dev/null
+++ b/roles/hark/templates/hark.default.j2
@@ -0,0 +1,2 @@
+PORTS="{% for port in hark_ports %}--port {{ port }} {% endfor %}"
+
diff --git a/services.common.yml b/services.common.yml
index 49977876..4151eb8f 100644
--- a/services.common.yml
+++ b/services.common.yml
@@ -214,3 +214,24 @@ data-exchange:
     - name: data-exchange
       port: 5792
       scheme: http
+
+hark:
+  scheduling_group: all
+  monitoring_endpoints:
+    - job_name: hark
+      port: 9419
+      scheme: http
+  systemd_services:
+    - hark.service
+  ports:
+    - 23
+    - 79
+    - 88
+    - 111
+    - 161
+    - 631
+    - 1080
+    - 6000
+    - 8000
+    - 8080
+
-- 
GitLab