Add yanic role (mostly copy&paste from Bremen)

This commit is contained in:
Markus 2017-06-11 20:26:34 +02:00
parent 6f071c524a
commit 6cccf81de2
11 changed files with 176 additions and 0 deletions

7
roles/go/tasks/main.yml Normal file
View File

@ -0,0 +1,7 @@
---
- name: Download and install go
unarchive: src=https://storage.googleapis.com/golang/go1.8.1.linux-amd64.tar.gz dest=/usr/local copy=no
- name: Configure go
template: src=go.sh dest=/etc/profile.d/go.sh

2
roles/go/templates/go.sh Normal file
View File

@ -0,0 +1,2 @@
export GOPATH=/opt/go
export PATH=$PATH:/usr/local/go/bin:$GOPATH/bin

View File

@ -0,0 +1,35 @@
---
yanic_publisher: false
yanic_respondd: true
yanic_respondd_collect_interval: "1m"
yanic_respondd_interface: "br-{{ site_code }}"
yanic_webserver: false
yanic_webserver_bind: "127.0.0.1:8080"
yanic_webserver_webroot: "/var/www/html/meshviewer"
yanic_nodes: true
yanic_nodes_state_path: "/var/lib/yanic/yanic.json"
yanic_nodes_save_interval: "5s"
yanic_nodes_offline_after: "10m"
yanic_nodes_prune_after: "7d"
yanic_meshviewer_version: 2
yanic_meshviewer_path: "/var/www/html/meshviewer/data"
yanic_meshviewer_nodes: "{{yanic_meshviewer_path}}/nodes.json"
yanic_meshviewer_graph: "{{yanic_meshviewer_path}}/graph.json"
yanic_database_delete_after: "7d"
yanic_database_delete_interval: "1h"
yanic_socket:
- enable: false
type: unix
address: "/var/lib/yanic/database.socket"
yanic_influxdb:
- enable: false
host: http://localhost:8086
database: ffhb
username: ""
password: ""

View File

@ -0,0 +1,9 @@
---
- name: Restart yanic
service: name=yanic state=restarted
- name: Restart yanic-publish
service: name=yanic-publish.timer state=restarted
- name: Reload systemd
command: systemctl daemon-reload

View File

@ -0,0 +1,4 @@
---
dependencies:
- { role: go }

View File

@ -0,0 +1,43 @@
---
- name: Create users
user: name=yanic generate_ssh_key=yes ssh_key_type=rsa ssh_key_file=.ssh/id_rsa ssh_key_comment="yanic@{{inventory_hostname}}"
- name: Install yanic
shell: /usr/local/go/bin/go get -u github.com/FreifunkBremen/yanic/cmd/yanic
environment:
GOPATH: /opt/go
notify: Restart yanic
- name: Configure yanic
template: src=config.toml dest=/etc/yanic.conf
notify: Restart yanic
- name: Create directories
file: path={{ item }}/ state=directory owner=yanic
with_items:
- "{{ yanic_meshviewer_path }}"
- /var/lib/yanic
- name: Install system unit
template: src=yanic.service dest=/lib/systemd/system/yanic.service
notify:
- Reload systemd
- Restart yanic
- name: Enable yanic
service: name=yanic enabled=yes
- name: Install system publish unit
template: src={{item}} dest=/lib/systemd/system/{{item}}
when: yanic_publisher
with_items:
- yanic-publish.service
- yanic-publish.timer
notify:
- Reload systemd
- Restart yanic-publish
- name: Enable yanic-publish
service: name=yanic-publish.timer enabled=yes
when: yanic_publisher

View File

@ -0,0 +1,43 @@
# {{ ansible_managed }}
[respondd]
enable = {{ yanic_respondd | ternary('true','false') }}
collect_interval = "{{ yanic_respondd_collect_interval }}"
interface = "{{ yanic_respondd_interface }}"
[webserver]
enable = {{ yanic_webserver | ternary('true','false') }}
bind = "{{ yanic_webserver_bind }}"
webroot = "{{ yanic_webserver_webroot }}"
[nodes]
enable = {{yanic_nodes | ternary('true','false') }}
state_path = "{{yanic_nodes_state_path}}"
save_interval = "{{yanic_nodes_save_interval}}"
offline_after = "{{yanic_nodes_offline_after}}"
prune_after = "{{yanic_nodes_prune_after}}"
[meshviewer]
version = {{yanic_meshviewer_version}}
nodes_path = "{{yanic_meshviewer_nodes}}"
graph_path = "{{yanic_meshviewer_graph}}"
[database]
delete_after = "{{ yanic_database_delete_after }}"
delete_interval = "{{ yanic_database_delete_interval }}"
{% for db in yanic_influxdb %}
[[database.connection.influxdb]]
enable = {{ db.enable | ternary('true','false') }}
address = "{{ db.host }}"
database = "{{ db.database }}"
username = "{{ db.username }}"
password = "{{ db.password }}"
{% endfor %}
{% for db in yanic_socket %}
[[database.connection.socket]]
enable = {{ db.enable | ternary('true','false') }}
type = "{{ db.type }}"
address = "{{ db.address }}"
{% endfor %}

View File

@ -0,0 +1,10 @@
[Unit]
Description=Publish data of yanic on downloads server
[Service]
ExecStart=/usr/bin/rsync --del -rt {{ yanic_nodes_path }}/ downloads@webserver.bremen.freifunk.net:data/yanic
User=yanic
Type=oneshot
[Install]
WantedBy=multi-user.target

View File

@ -0,0 +1,9 @@
[Unit]
Description=Publish data of yanic on downloads server every minute
[Timer]
OnBootSec=15min
OnUnitActiveSec=1min
[Install]
WantedBy=timers.target

View File

@ -0,0 +1,13 @@
[Unit]
Description=yanic
[Service]
Type=simple
User=yanic
ExecStart=/opt/go/bin/yanic -config /etc/yanic.conf
Restart=always
RestartSec=5s
Environment=PATH=/usr/bin:/usr/local/bin
[Install]
WantedBy=multi-user.target

View File

@ -17,6 +17,7 @@
- dns
- dhcpd
- respondd
- yanic
- name: Setup confluence server
hosts: confluence.regensburg.freifunk.net