add role service-yanic

This commit is contained in:
Julian Labus 2018-09-11 14:20:44 +02:00
parent c65d39ee54
commit 57a42f17de
No known key found for this signature in database
GPG key ID: 8AF209F2C6B3572A
7 changed files with 142 additions and 0 deletions

View file

@ -14,3 +14,8 @@ prometheus_components:
- prometheus - prometheus
- alertmanager - alertmanager
- node_exporter - node_exporter
gopath: "/opt/go"
yanic_blacklist:
- 98ded0c5e0c0

View file

@ -0,0 +1,6 @@
---
yanic_user: "yanic"
yanic_home: "/var/lib/yanic"
yanic_path: "{{ gopath }}/bin/yanic"
yanic_config: "/etc/yanic.conf"
yanic_database: "yanic"

View file

@ -0,0 +1,9 @@
---
- name: reload systemd
systemd:
daemon_reload: yes
- name: restart yanic
systemd:
name: yanic
state: restarted

View file

@ -0,0 +1,4 @@
---
dependencies:
- { role: golang }
- { role: service-influxdb }

View file

@ -0,0 +1,40 @@
---
- name: create Yanic system user
user:
name: "{{ yanic_user }}"
home: "{{ yanic_home }}"
shell: /bin/false
- name: create data dir
file:
path: "{{ yanic_home }}/data"
state: directory
owner: yanic
group: yanic
mode: 0755
- name: create database
influxdb_database:
database_name: "{{ yanic_database }}"
- name: write Yanic config
template:
src: "yanic.conf.j2"
dest: "{{ yanic_config }}"
notify: restart yanic
- name: create systemd unit for Yanic
template:
src: "yanic.service.j2"
dest: "/etc/systemd/system/yanic.service"
notify: reload systemd
- name: build Yanic binary
shell: "GOPATH={{ gopath }} go get -v -u github.com/FreifunkBremen/yanic"
notify: restart yanic
- name: configure Yanic systemd unit
systemd:
name: "yanic.service"
enabled: yes
state: started

View file

@ -0,0 +1,60 @@
#
# {{ ansible_managed }}
#
[respondd]
enable = true
synchronize = "1m"
collect_interval = "1m"
{% for mesh in meshes %}
[respondd.sites.{{ mesh.site_code }}]
{% if mesh.sites_virtual is defined %}
{% for site, name in mesh.sites_virtual.items() %}
[respondd.sites.{{ site }}]
{% endfor %}
{% endif %}
{% endfor %}
{% for mesh in meshes %}
[[respondd.interfaces]]
ifname = "{{mesh.id}}br"
{% endfor %}
[nodes]
state_path = "/var/lib/yanic/state.json"
prune_after = "30d"
save_interval = "5s"
offline_after = "10m"
[[nodes.output.meshviewer-ffrgb]]
enable = true
path = "/var/lib/yanic/data/meshviewer.json"
[nodes.output.meshviewer-ffrgb.filter]
no_owner = true
{% if yanic_blacklist is defined %}
blacklist = [{% for node in yanic_blacklist %}"{{ node }}"{% if not loop.last %},{% endif %}{% endfor %}]
{% endif %}
[[nodes.output.meshviewer]]
enable = true
version = 2
nodes_path = "/var/lib/yanic/data/nodes.json"
graph_path = "/var/lib/yanic/data/graph.json"
[nodes.output.meshviewer.filter]
no_owner = true
[[nodes.output.nodelist]]
enable = true
path = "/var/lib/yanic/data/nodelist.json"
[database]
delete_after = "30d"
delete_interval = "1h"
[[database.connection.influxdb]]
enable = true
address = "http://localhost:8086"
database = "yanic"
username = ""
password = ""

View file

@ -0,0 +1,18 @@
[Unit]
Description=Yanic - Yet another node info collector
Documentation=https://github.com/FreifunkBremen/yanic
Wants=network-online.target
After=network-online.target
[Service]
Type=simple
User={{ yanic_user }}
Group={{ yanic_user }}
ExecStart={{ yanic_path }} serve --config {{ yanic_config }}
Restart=always
RestartSec=5s
[Install]
WantedBy=multi-user.target