From 9ec1670a262597356c24bff27d473eccceb45b61 Mon Sep 17 00:00:00 2001 From: Niklas Yann Wettengel Date: Wed, 28 Jul 2021 01:12:10 +0200 Subject: wg --- roles/install_wgkex/files/wgkex.service | 12 +++++++++ roles/install_wgkex/handlers/main.yml | 5 ++++ roles/install_wgkex/tasks/main.yml | 42 +++++++++++++++++++++++++++++ roles/install_wgkex/templates/wgkex.yaml.j2 | 12 +++++++++ 4 files changed, 71 insertions(+) create mode 100644 roles/install_wgkex/files/wgkex.service create mode 100644 roles/install_wgkex/handlers/main.yml create mode 100644 roles/install_wgkex/tasks/main.yml create mode 100644 roles/install_wgkex/templates/wgkex.yaml.j2 (limited to 'roles/install_wgkex') diff --git a/roles/install_wgkex/files/wgkex.service b/roles/install_wgkex/files/wgkex.service new file mode 100644 index 0000000..c549cf3 --- /dev/null +++ b/roles/install_wgkex/files/wgkex.service @@ -0,0 +1,12 @@ +[Unit] +Description=wgkex +After=network.target + +[Service] +ExecStart=/opt/wgkex/.venv/bin/python /opt/wgkex/wgkex/worker/app.py +Restart=always +WorkingDirectory=/opt/wgkex +Environment=PYTHONPATH=/opt/wgkex + +[Install] +WantedBy=multi-user.target diff --git a/roles/install_wgkex/handlers/main.yml b/roles/install_wgkex/handlers/main.yml new file mode 100644 index 0000000..4b2e853 --- /dev/null +++ b/roles/install_wgkex/handlers/main.yml @@ -0,0 +1,5 @@ +--- +- name: restart wgkex + systemd: + name: wgkex.service + state: restarted diff --git a/roles/install_wgkex/tasks/main.yml b/roles/install_wgkex/tasks/main.yml new file mode 100644 index 0000000..c8b3264 --- /dev/null +++ b/roles/install_wgkex/tasks/main.yml @@ -0,0 +1,42 @@ +--- +- name: install wgkex dependencies + pacman: + name: + - git + - python-virtualenv + - python-setuptools + state: present + +- name: clone wgkex repo + git: + repo: https://github.com/FreifunkMYK/wgkex.git + dest: /opt/wgkex + +- name: create venv + command: + cmd: "python -m venv /opt/wgkex/.venv" + creates: /opt/wgkex/.venv + +- name: install requirements + pip: + requirements: /opt/wgkex/requirements.txt + virtualenv: /opt/wgkex/.venv + +- name: install wgkex config + template: + src: wgkex.yaml.j2 + dest: /etc/wgkex.yaml + mode: 0644 + notify: restart wgkex + +- name: create wgkex service + copy: + src: wgkex.service + dest: /etc/systemd/system/wgkex.service + mode: 0644 + +- name: start and enable wgkex service + systemd: + name: wgkex + state: started + enabled: yes diff --git a/roles/install_wgkex/templates/wgkex.yaml.j2 b/roles/install_wgkex/templates/wgkex.yaml.j2 new file mode 100644 index 0000000..a8aec9c --- /dev/null +++ b/roles/install_wgkex/templates/wgkex.yaml.j2 @@ -0,0 +1,12 @@ +--- +domains: +{% for site in sites %} + - ff{{ site.name }} +{% endfor %} +mqtt: + broker_url: "{{ wgkex_host }}" + broker_port: {{ wgkex_port }} + username: "{{ wgkex_username }}" + password: "{{ wgkex_password }}" + keepalive: 5 + tls: True -- cgit v1.2.3-54-g00ecf