add role service-yanic
This commit is contained in:
parent
c65d39ee54
commit
57a42f17de
7 changed files with 142 additions and 0 deletions
|
@ -14,3 +14,8 @@ prometheus_components:
|
||||||
- prometheus
|
- prometheus
|
||||||
- alertmanager
|
- alertmanager
|
||||||
- node_exporter
|
- node_exporter
|
||||||
|
|
||||||
|
gopath: "/opt/go"
|
||||||
|
|
||||||
|
yanic_blacklist:
|
||||||
|
- 98ded0c5e0c0
|
||||||
|
|
6
roles/service-yanic/defaults/main.yml
Normal file
6
roles/service-yanic/defaults/main.yml
Normal 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"
|
9
roles/service-yanic/handlers/main.yml
Normal file
9
roles/service-yanic/handlers/main.yml
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
---
|
||||||
|
- name: reload systemd
|
||||||
|
systemd:
|
||||||
|
daemon_reload: yes
|
||||||
|
|
||||||
|
- name: restart yanic
|
||||||
|
systemd:
|
||||||
|
name: yanic
|
||||||
|
state: restarted
|
4
roles/service-yanic/meta/main.yml
Normal file
4
roles/service-yanic/meta/main.yml
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
---
|
||||||
|
dependencies:
|
||||||
|
- { role: golang }
|
||||||
|
- { role: service-influxdb }
|
40
roles/service-yanic/tasks/main.yml
Normal file
40
roles/service-yanic/tasks/main.yml
Normal 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
|
60
roles/service-yanic/templates/yanic.conf.j2
Normal file
60
roles/service-yanic/templates/yanic.conf.j2
Normal 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 = ""
|
18
roles/service-yanic/templates/yanic.service.j2
Normal file
18
roles/service-yanic/templates/yanic.service.j2
Normal 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
|
Loading…
Reference in a new issue