From a3f353c2027fa7499f00121a403de556e94d6a1c Mon Sep 17 00:00:00 2001 From: Oliver Gerlich Date: Wed, 25 May 2022 19:40:51 +0200 Subject: [PATCH 1/4] go: make /etc/profile.d/go.sh executable This was also changed on the actual server in 2016, so it's probably necessary. --- roles/go/tasks/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/go/tasks/main.yml b/roles/go/tasks/main.yml index 8242e75e..df646e33 100644 --- a/roles/go/tasks/main.yml +++ b/roles/go/tasks/main.yml @@ -9,6 +9,6 @@ template: src: go.sh dest: /etc/profile.d/go.sh - mode: 0644 + mode: 0755 owner: root group: root From bfa8349278e24bddfefac19063ff1b5ffa8b123c Mon Sep 17 00:00:00 2001 From: Oliver Gerlich Date: Wed, 25 May 2022 21:30:44 +0200 Subject: [PATCH 2/4] yanic: set yanic_nodes_paths variable --- playbooks/ffmapserver.yml | 1 + roles/yanic/defaults/main.yml | 2 ++ roles/yanic/templates/yanic-publish.service | 2 +- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/playbooks/ffmapserver.yml b/playbooks/ffmapserver.yml index fc2da012..3896f7af 100644 --- a/playbooks/ffmapserver.yml +++ b/playbooks/ffmapserver.yml @@ -14,6 +14,7 @@ database: "ffhb-nodes" username: "ffhb-respondd-collector" password: "" + yanic_nodes_paths: /opt/yanic/v1 /opt/yanic/v2 /opt/yanic/meshviewer.json /opt/yanic/respondd-crashed.json /opt/yanic/nodelist.json /opt/yanic/geojson.json roles: - { role: etckeeper-pre, tags: [etckeeper-pre] } - { role: yanic, tags: [yanic] } diff --git a/roles/yanic/defaults/main.yml b/roles/yanic/defaults/main.yml index a76182c8..4a8d6e92 100644 --- a/roles/yanic/defaults/main.yml +++ b/roles/yanic/defaults/main.yml @@ -32,3 +32,5 @@ yanic_influxdb: database: ffhb username: "" password: "" + +yanic_nodes_paths: "{{yanic_meshviewer_path}}" diff --git a/roles/yanic/templates/yanic-publish.service b/roles/yanic/templates/yanic-publish.service index fc186dff..06dae93d 100644 --- a/roles/yanic/templates/yanic-publish.service +++ b/roles/yanic/templates/yanic-publish.service @@ -2,7 +2,7 @@ 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 +ExecStart=/usr/bin/rsync --del -rt {{ yanic_nodes_paths }} downloads@webserver.bremen.freifunk.net:data/yanic User=yanic Type=oneshot From 827fe98dbcde6647987e2949148387cac503e215 Mon Sep 17 00:00:00 2001 From: Oliver Gerlich Date: Wed, 25 May 2022 21:32:59 +0200 Subject: [PATCH 3/4] yanic: change .service files to match contents of actual ffmap server --- roles/yanic/templates/yanic-publish.service | 2 +- roles/yanic/templates/yanic.service | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/roles/yanic/templates/yanic-publish.service b/roles/yanic/templates/yanic-publish.service index 06dae93d..f64719f0 100644 --- a/roles/yanic/templates/yanic-publish.service +++ b/roles/yanic/templates/yanic-publish.service @@ -2,7 +2,7 @@ Description=Publish data of yanic on downloads server [Service] -ExecStart=/usr/bin/rsync --del -rt {{ yanic_nodes_paths }} downloads@webserver.bremen.freifunk.net:data/yanic +ExecStart=/usr/bin/rsync -l --del -rt {{ yanic_nodes_paths }} downloads@webserver.bremen.freifunk.net:data/ User=yanic Type=oneshot diff --git a/roles/yanic/templates/yanic.service b/roles/yanic/templates/yanic.service index 82e44a5b..0a2193cb 100644 --- a/roles/yanic/templates/yanic.service +++ b/roles/yanic/templates/yanic.service @@ -4,7 +4,7 @@ Description=yanic [Service] Type=simple User=yanic -ExecStart=/opt/go/bin/yanic -config /etc/yanic.conf +ExecStart=/opt/go/bin/yanic serve --config /etc/yanic.conf --timestamps --loglevel 40 Restart=always RestartSec=5s Environment=PATH=/usr/bin:/usr/local/bin From 07b27c9c574987d84185f1f6d9ab05131c7de793 Mon Sep 17 00:00:00 2001 From: Oliver Gerlich Date: Wed, 25 May 2022 21:36:26 +0200 Subject: [PATCH 4/4] yanic: use static config file This uses the current config file taken from actual ffmap server, except that the (unused) influxdb2 access token was removed. --- playbooks/ffmapserver.yml | 12 +- roles/yanic/defaults/main.yml | 38 +----- roles/yanic/tasks/main.yml | 2 +- roles/yanic/templates/config.toml | 43 ------ roles/yanic/templates/yanic.conf.ffmapserver | 134 +++++++++++++++++++ 5 files changed, 143 insertions(+), 86 deletions(-) delete mode 100644 roles/yanic/templates/config.toml create mode 100644 roles/yanic/templates/yanic.conf.ffmapserver diff --git a/playbooks/ffmapserver.yml b/playbooks/ffmapserver.yml index 3896f7af..af5479c9 100644 --- a/playbooks/ffmapserver.yml +++ b/playbooks/ffmapserver.yml @@ -1,19 +1,9 @@ --- - hosts: ffmapserver vars: + yanic_config_file: yanic.conf.ffmapserver yanic_publisher: true - yanic_respondd_interface: "bat0" - yanic_webserver: false - yanic_nodes_save_interval: "15s" - yanic_nodes_state_path: /opt/yanic/nodes_state.json yanic_meshviewer_path: /opt/yanic - yanic_meshviewer_nodes: /opt/yanic/nodes_v2.json - yanic_influxdb: - - enable: "true" - host: http://webserver.bremen.freifunk.net:8086 - database: "ffhb-nodes" - username: "ffhb-respondd-collector" - password: "" yanic_nodes_paths: /opt/yanic/v1 /opt/yanic/v2 /opt/yanic/meshviewer.json /opt/yanic/respondd-crashed.json /opt/yanic/nodelist.json /opt/yanic/geojson.json roles: - { role: etckeeper-pre, tags: [etckeeper-pre] } diff --git a/roles/yanic/defaults/main.yml b/roles/yanic/defaults/main.yml index 4a8d6e92..4eba5ed8 100644 --- a/roles/yanic/defaults/main.yml +++ b/roles/yanic/defaults/main.yml @@ -1,36 +1,12 @@ --- -yanic_publisher: false -yanic_respondd: true -yanic_respondd_collect_interval: "1m" -yanic_respondd_interface: "eth0" - -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.json" -yanic_nodes_save_interval: "5s" -yanic_nodes_offline_after: "10m" -yanic_nodes_prune_after: "7d" +# Config file to use for yanic. +# There is no sensible default for the config file (it _must_ be specified for each host separately). +yanic_config_file: -yanic_meshviewer_version: 2 +# Directory for yanic results (will be created by Ansible role): 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: "" +# Whether the yanic results (from yanic_nodes_paths) should be periodically rsync'ed to the webserver. +yanic_publisher: false +# Path(es) to rsync to the webserver. yanic_nodes_paths: "{{yanic_meshviewer_path}}" diff --git a/roles/yanic/tasks/main.yml b/roles/yanic/tasks/main.yml index 66de4a58..36922336 100644 --- a/roles/yanic/tasks/main.yml +++ b/roles/yanic/tasks/main.yml @@ -25,7 +25,7 @@ - name: Configure yanic template: - src: config.toml + src: "{{ yanic_config_file }}" dest: /etc/yanic.conf mode: 0644 owner: root diff --git a/roles/yanic/templates/config.toml b/roles/yanic/templates/config.toml deleted file mode 100644 index 733a0dc4..00000000 --- a/roles/yanic/templates/config.toml +++ /dev/null @@ -1,43 +0,0 @@ -# {{ 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 %} diff --git a/roles/yanic/templates/yanic.conf.ffmapserver b/roles/yanic/templates/yanic.conf.ffmapserver new file mode 100644 index 00000000..7cbb3584 --- /dev/null +++ b/roles/yanic/templates/yanic.conf.ffmapserver @@ -0,0 +1,134 @@ +[respondd] +enable = true +collect_interval = "1m" + +[respondd.sites.ffhb] +domains = ["ffhb", "ffhb_legacy", "ffhb_11s", "servers", ""] + +[[respondd.interfaces]] +ifname = "br-ffhb" +port = 10001 + +[[respondd.interfaces]] +ifname = "br-ffhb" +multicast_address = "ff02::2:1001" + +[[respondd.interfaces]] +ifname = "eth0" +send_no_request = true +ip_address = "2a06:8782:ff00::f6" +port = 11001 + +[webserver] +enable = true +bind = ":8080" +webroot = "/opt/yanic/webroot" + +[webserver.prometheus] +enable = true +wait = "10s" +outdated = "60s" + + +[nodes] +state_path = "/opt/yanic/state.json" +save_interval = "1m" +offline_after = "10m" +prune_after = "7d" +# ping_count = 3 +# ping_timeout = "1s" + + +[[nodes.output.meshviewer]] +enable = true +version = 1 +nodes_path = "/opt/yanic/v1/nodes.json" +graph_path = "/opt/yanic/v1/graph.json" + +[nodes.output.meshviewer.filter] +no_owner = true + + +[[nodes.output.meshviewer]] +enable = true +version = 2 +nodes_path = "/opt/yanic/v2/nodes.json" +graph_path = "/opt/yanic/v2/graph.json" + +[nodes.output.meshviewer.filter] +no_owner = true + + +[[nodes.output.meshviewer-ffrgb]] +enable = true +path = "/opt/yanic/meshviewer.json" + +[nodes.output.meshviewer-ffrgb.filter] +no_owner = true + + +[[nodes.output.nodelist]] +enable = true +path = "/opt/yanic/nodelist.json" + +[nodes.output.nodelist.filter] +no_owner = true + +[[nodes.output.geojson]] +enable = true +path = "/opt/yanic/geojson.json" + +[[nodes.output.raw]] +enable = false + +[[nodes.output.raw-jsonl]] +enable = false + +[[nodes.output.prometheus-sd]] +enable = true +#path = "/var/lib/freifunkmanager/metrics" +path = "/opt/yanic/webroot/index.html" +target_address = "node_id" + +[nodes.output.prometheus-sd.labels] +hosts = "ffhb" +service = "yanic" + + +[database] +delete_after = "7d" +delete_interval = "1h" + +[[database.connection.influxdb]] +enable = true +address = "http://webserver.bremen.freifunk.net:8086" +database = "{{respond_collector_influxdb_database}}" +username = "{{respond_collector_influxdb_username}}" +password = "{{respond_collector_influxdb_password}}" + +[[database.connection.influxdb2]] +enable = false +address = "http://webserver.bremen.freifunk.net:8086" +token = "" +organization_id = "ffhb" +bucket_default = "yanic-temp" + +[database.connection.influxdb2.buckets] +global = "ffhb-nodes/autogen" +firmware = "ffhb-nodes/autogen" +model = "ffhb-nodes/autogen" +autoupdater = "ffhb-nodes/autogen" + +[database.connection.influxdb2.tags] +system = "production" + +[[database.connection.graphite]] +enable = false + +[[database.connection.logging]] +enable = false + +[[database.connection.respondd]] +enable = false +type = "udp6" +address = "[::1]:10001"