From 8ead2bc0fee83265e5d4df51452992a273968156 Mon Sep 17 00:00:00 2001 From: Pierre-Olivier Mercier Date: Wed, 15 Mar 2023 22:16:43 +0100 Subject: [PATCH] Include needed scripts --- files/wg-sync.sh | 8 ++++++++ tasks/container-setup.yml | 2 +- tasks/main.yml | 18 ++++++++++++++++++ tasks/networking.yml | 8 ++++++++ 4 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 files/wg-sync.sh diff --git a/files/wg-sync.sh b/files/wg-sync.sh new file mode 100644 index 0000000..9953fcf --- /dev/null +++ b/files/wg-sync.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +{ + cat /etc/wg-adlin.conf + curl -s https://adlin.nemunai.re/api/wg.conf + +} > /tmp/wg-adlin.conf && + wg addconf wg-adlin /tmp/wg-adlin.conf diff --git a/tasks/container-setup.yml b/tasks/container-setup.yml index f6108e2..f5a466a 100644 --- a/tasks/container-setup.yml +++ b/tasks/container-setup.yml @@ -94,7 +94,7 @@ name: "{{ ctr_name }}" container_command: | echo nameserver 192.168.0.254 > /etc/resolv.conf; - apk add --no-cache wireguard-tools-wg nftables; + apk add --no-cache curl wireguard-tools-wg nftables; state: started - name: Create symlink for service diff --git a/tasks/main.yml b/tasks/main.yml index a58d350..fb8fa8d 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -15,11 +15,29 @@ state: directory # 3. Install others scripts +- name: configure wg-adlin + copy: + src: "/etc/wireguard/wg-adlin.conf" + dest: "/var/lib/lxc/{{ ctr_name }}/rootfs/etc/wg-adlin.conf" + remote_src: true + tags: + - wireguard + +- name: Copy wg-sync.sh + copy: + src: "wg-sync.sh" + dest: "/var/lib/lxc/{{ ctr_name }}/rootfs/root/wg-sync.sh" + mode: 0755 + tags: + - wireguard + - name: Retrieve clean-wg.sh get_url: url: https://git.nemunai.re/teach/adlin/raw/branch/master/token-validator/clean-wg.sh dest: "/var/lib/lxc/{{ ctr_name }}/rootfs/usr/sbin/clean-wg.sh" mode: 0755 + tags: + - wireguard - name: Add update-adlin script template: diff --git a/tasks/networking.yml b/tasks/networking.yml index ebfaed1..9cd875c 100644 --- a/tasks/networking.yml +++ b/tasks/networking.yml @@ -4,6 +4,8 @@ name: - wireguard-tools-wg state: present + tags: + - wireguard - name: Enable IPv6 forwarding ansible.posix.sysctl: @@ -15,14 +17,20 @@ file: path: /etc/wireguard state: directory + tags: + - wireguard - name: configure wg-adlin template: src: "wg.conf.j2" dest: "/etc/wireguard/wg-adlin.conf" + tags: + - wireguard - name: enable wg-adlin template: src: networking.j2 dest: "/etc/network/interfaces.d/wg-adlin" notify: restart networking + tags: + - wireguard