Add yanic role (mostly copy&paste from Bremen)
This commit is contained in:
parent
6f071c524a
commit
6cccf81de2
7
roles/go/tasks/main.yml
Normal file
7
roles/go/tasks/main.yml
Normal 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
2
roles/go/templates/go.sh
Normal file
@ -0,0 +1,2 @@
|
||||
export GOPATH=/opt/go
|
||||
export PATH=$PATH:/usr/local/go/bin:$GOPATH/bin
|
35
roles/yanic/defaults/main.yml
Normal file
35
roles/yanic/defaults/main.yml
Normal 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: ""
|
9
roles/yanic/handlers/main.yml
Normal file
9
roles/yanic/handlers/main.yml
Normal 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
|
4
roles/yanic/meta/main.yml
Normal file
4
roles/yanic/meta/main.yml
Normal file
@ -0,0 +1,4 @@
|
||||
---
|
||||
|
||||
dependencies:
|
||||
- { role: go }
|
43
roles/yanic/tasks/main.yml
Normal file
43
roles/yanic/tasks/main.yml
Normal 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
|
43
roles/yanic/templates/config.toml
Normal file
43
roles/yanic/templates/config.toml
Normal 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 %}
|
10
roles/yanic/templates/yanic-publish.service
Normal file
10
roles/yanic/templates/yanic-publish.service
Normal 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
|
9
roles/yanic/templates/yanic-publish.timer
Normal file
9
roles/yanic/templates/yanic-publish.timer
Normal 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
|
13
roles/yanic/templates/yanic.service
Normal file
13
roles/yanic/templates/yanic.service
Normal 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
|
Loading…
Reference in New Issue
Block a user