summaryrefslogtreecommitdiff
path: root/spreadspace
diff options
context:
space:
mode:
authorChristian Pointner <equinox@spreadspace.org>2021-04-09 15:12:36 +0200
committerChristian Pointner <equinox@spreadspace.org>2021-04-09 15:12:36 +0200
commit4775b1ddbfea5045f3469d4afae45e8389a26d0f (patch)
tree6ab7ffd0766e5a7725f57cc81a88f1a5c2607e0e /spreadspace
parentinstall iptraf-ng on glt-gw-r3 (diff)
glt-stream: deploy minimalistics stats collector (WIP)
Diffstat (limited to 'spreadspace')
-rw-r--r--spreadspace/glt-stream.yml63
1 files changed, 63 insertions, 0 deletions
diff --git a/spreadspace/glt-stream.yml b/spreadspace/glt-stream.yml
index 355c989f..48541d85 100644
--- a/spreadspace/glt-stream.yml
+++ b/spreadspace/glt-stream.yml
@@ -46,3 +46,66 @@
autoindex: {}
include_role:
name: nginx/vhost
+
+ - name: install golang
+ apt:
+ name: go
+ state: present
+
+ - name: create base directory for stats
+ file:
+ path: /srv/www/stats
+ state: directory
+
+ - name: add user for stats
+ user:
+ name: stats
+ system: yes
+ home: /srv/www/stats
+
+ - name: create data and gocache directories for stats
+ loop:
+ - data
+ - .gocache
+ file:
+ path: "/srv/www/stats/{{ item }}"
+ state: directory
+ group: stats
+ mode: 0775
+
+ - name: install stats collector script
+ copy:
+ src: "{{ global_files_dir }}/glt/stream-stats.go"
+ dest: /srv/www/stats/stream-stats.go
+
+ - name: install systemd unit for stats collector
+ copy:
+ content: |
+ [Unit]
+ Description=GLT21 Stream Stats Collector
+
+ [Service]
+ Type=simple
+ Environment="GOCACHE=/srv/www/stats/.gocache"
+ ExecStart=/usr/bin/go run /srv/www/stats/stream-stats.go 127.0.0.1:4200 /srv/www/stats/data/glt21.json
+ NoNewPrivileges=yes
+ PrivateTmp=yes
+ PrivateDevices=yes
+ ProtectSystem=strict
+ ReadWritePaths=/srv/www/stats/data /srv/www/stats/.gocache
+ ProtectHome=yes
+ ProtectKernelTunables=yes
+ ProtectControlGroups=yes
+ RestrictRealtime=yes
+ RestrictAddressFamilies=AF_INET
+
+ [Install]
+ WantedBy=multi-user.target
+ dest: /etc/systemd/system/stream-stats.service
+
+ - name: make sure stats collector service unit is enabled and started
+ systemd:
+ name: stream-stats.service
+ daemon_reload: yes
+ enabled: yes
+ state: started