diff --git a/roles/service-yanic/README.md b/roles/service-yanic/README.md index f56535c..c61686a 100644 --- a/roles/service-yanic/README.md +++ b/roles/service-yanic/README.md @@ -5,10 +5,13 @@ Diese Ansible role installiert Yanic. - legt den Benutzer und Gruppe für Yanic an - legt das Yanic Verzeichnis aus - legt die InfluxDB Datenbank für Yanic an +- kompiliert und installiert Yanic - schreibt yanic.conf - schreibt yanic.service -- kompiliert und installiert Yanic +- schreibt respondd.conf +- schreibt respondd.service - aktiviert die systemd unit `yanic.service` +- aktiviert die systemd unit `respondd.service` # Benötigte Variablen @@ -19,5 +22,6 @@ Diese Ansible role installiert Yanic. - Variable `yanic_user` - Variable `yanic_home` - Variable `yanic_path` -- Variable `yanic_config` - Variable `yanic_database` +- Variable `yanic_config` +- Variable `respondd_config` diff --git a/roles/service-yanic/defaults/main.yml b/roles/service-yanic/defaults/main.yml index cd02ccb..7bdd472 100644 --- a/roles/service-yanic/defaults/main.yml +++ b/roles/service-yanic/defaults/main.yml @@ -2,6 +2,7 @@ yanic_user: "yanic" yanic_home: "/var/lib/yanic" yanic_path: "{{ gopath }}/bin/yanic" -yanic_config: "/etc/yanic.conf" yanic_database: "yanic" yanic_src: "github.com/FreifunkBremen/yanic" +yanic_config: "/etc/yanic.conf" +respondd_config: "/etc/respondd.conf" diff --git a/roles/service-yanic/handlers/main.yml b/roles/service-yanic/handlers/main.yml index 49bf8c8..5244237 100644 --- a/roles/service-yanic/handlers/main.yml +++ b/roles/service-yanic/handlers/main.yml @@ -7,3 +7,8 @@ systemd: name: yanic state: restarted + +- name: restart respondd + systemd: + name: respondd + state: restarted diff --git a/roles/service-yanic/meta/main.yml b/roles/service-yanic/meta/main.yml index fdc1d82..cd0b89c 100644 --- a/roles/service-yanic/meta/main.yml +++ b/roles/service-yanic/meta/main.yml @@ -1,4 +1,3 @@ --- dependencies: - - { role: golang } - - { role: service-influxdb } +# - { role: golang } diff --git a/roles/service-yanic/tasks/main.yml b/roles/service-yanic/tasks/main.yml index 3246e4a..7263d55 100644 --- a/roles/service-yanic/tasks/main.yml +++ b/roles/service-yanic/tasks/main.yml @@ -1,62 +1,35 @@ --- -- name: set facts about Yanic - set_fact: - yanic_present: yes - -- name: create Yanic system user +- name: create 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: create Yanic source directory +- name: create source directory file: path: "{{ gopath }}/src/{{ yanic_src }}" state: directory -- name: clone Yanic repository +- name: clone repository git: repo: "https://{{ yanic_src }}" dest: "{{ gopath }}/src/{{ yanic_src }}" + version: respondd force: true -- name: get required library versions +- name: ensure dependencies shell: "cd {{ gopath }}/src/{{ yanic_src }} && {{ gopath }}/bin/dep ensure" environment: GOPATH: "{{ gopath }}" -- name: build Yanic binary +- name: build binary shell: 'go install {{ gopath }}/src/{{ yanic_src }}' environment: GOPATH: "{{ gopath }}" - notify: restart yanic -- name: configure Yanic systemd unit - systemd: - name: "yanic.service" - enabled: yes - state: started +- name: configure yanic + include_tasks: yanic.yml + when: server_type == "monitoring" + +- name: configure respondd + include_tasks: respondd.yml diff --git a/roles/service-yanic/tasks/respondd.yml b/roles/service-yanic/tasks/respondd.yml new file mode 100644 index 0000000..764ddae --- /dev/null +++ b/roles/service-yanic/tasks/respondd.yml @@ -0,0 +1,18 @@ +--- +- name: write config + template: + src: "respondd.conf.j2" + dest: "{{ respondd_config }}" + notify: restart respondd + +- name: create systemd unit + template: + src: "respondd.service.j2" + dest: "/etc/systemd/system/respondd.service" + notify: reload systemd + +- name: configure systemd unit + systemd: + name: "respondd.service" + enabled: yes + state: started diff --git a/roles/service-yanic/tasks/yanic.yml b/roles/service-yanic/tasks/yanic.yml new file mode 100644 index 0000000..8ea116f --- /dev/null +++ b/roles/service-yanic/tasks/yanic.yml @@ -0,0 +1,34 @@ +--- +- name: set facts + set_fact: + yanic_present: yes + +- 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 config + template: + src: "yanic.conf.j2" + dest: "{{ yanic_config }}" + notify: restart yanic + +- name: create systemd unit + template: + src: "yanic.service.j2" + dest: "/etc/systemd/system/yanic.service" + notify: reload systemd + +- name: configure systemd unit + systemd: + name: "yanic.service" + enabled: yes + state: started diff --git a/roles/service-yanic/templates/respondd.conf.j2 b/roles/service-yanic/templates/respondd.conf.j2 new file mode 100644 index 0000000..cfb3012 --- /dev/null +++ b/roles/service-yanic/templates/respondd.conf.j2 @@ -0,0 +1,20 @@ +data_interval = "1m" + +batman = [ {% for mesh in meshes %}"{{mesh.id}}bat"{% if not loop.last %}, {% endif %}{% endfor %}] + +[[listen]] +address = "ff05::2:1001" +interface = "dom0br" +port = 1001 + +[defaults] +node_id = "" +hostname = "" +site_code = "ffmwu" +domain_code = "servers" +{% if server_type == "gateway" %} +vpn = true +{% else %} +vpn = false +{% endif %} +traffic_interfaces = [ "{{ ansible_default_ipv4.interface }}" ] diff --git a/roles/service-yanic/templates/respondd.service.j2 b/roles/service-yanic/templates/respondd.service.j2 new file mode 100644 index 0000000..523ee2e --- /dev/null +++ b/roles/service-yanic/templates/respondd.service.j2 @@ -0,0 +1,15 @@ +[Unit] +Description=respondd +Documentation=https://github.com/FreifunkBremen/yanic +Wants=network-online.target +After=network-online.target + +[Service] +Type=simple + +ExecStart={{ yanic_path }} respondd --config {{ respondd_config }} +Restart=always +RestartSec=5s + +[Install] +WantedBy=multi-user.target diff --git a/roles/service-yanic/templates/yanic.conf.j2 b/roles/service-yanic/templates/yanic.conf.j2 index 5d575bf..924d242 100644 --- a/roles/service-yanic/templates/yanic.conf.j2 +++ b/roles/service-yanic/templates/yanic.conf.j2 @@ -25,6 +25,12 @@ domains = [ {% for mesh in meshes %} [[respondd.interfaces]] ifname = "{{mesh.id}}br" +{% if mesh.legacy is defined %} +ip_address = "{{ 'fe80::1:aff:fe%02x:%02x' % (mesh.domain_number, magic) }}" +{% else %} +ip_address = "{{ 'fe80::1:aff:fe56:%0x%03x' % (mesh.domain_number, magic) }}" +{% endif %} +multicast_address = "ff05::2:1001" {% endfor %} [nodes]