Merge branch 'role_wireguard-ipv6-converter'
commit
15ad7920d4
@ -0,0 +1,12 @@
|
|||||||
|
wireguard_ipv6_converter:
|
||||||
|
version: latest
|
||||||
|
|
||||||
|
# see https://github.com/Ruakij/wg-ipv6-converter#31-environment
|
||||||
|
setup:
|
||||||
|
interface: wg0
|
||||||
|
#ipv6_format: fc12::%02x%02x:%02x%02x/%d
|
||||||
|
#filter_prefix: 100.100
|
||||||
|
#recheck_interval: 60s
|
||||||
|
|
||||||
|
service:
|
||||||
|
#bindTo: netbird.service
|
@ -0,0 +1,11 @@
|
|||||||
|
- name: Get architecture
|
||||||
|
set_fact:
|
||||||
|
arch: "{{ 'amd64' if ansible_architecture == 'x86_64' else 'arm64' }}"
|
||||||
|
versionUri: "{% if wireguard_ipv6_converter.version == 'latest' %}latest/download{% else %}download/{{ wireguard_ipv6_converter.version }}{% endif %}"
|
||||||
|
|
||||||
|
- name: Download binary
|
||||||
|
get_url:
|
||||||
|
url: https://github.com/Ruakij/wg-ipv6-converter/releases/{{ versionUri }}/wg-ipv6-converter_{{ arch }}
|
||||||
|
dest: /usr/local/bin/wg-ipv6-converter
|
||||||
|
mode: "744"
|
||||||
|
register: deployDownload
|
@ -0,0 +1,3 @@
|
|||||||
|
- import_tasks: ./deploy.yml
|
||||||
|
|
||||||
|
- import_tasks: ./setup-service.yml
|
@ -0,0 +1,17 @@
|
|||||||
|
- name: Deploy service
|
||||||
|
ansible.builtin.template:
|
||||||
|
src: wg-ipv6-conv.service.jinja2
|
||||||
|
dest: /etc/systemd/system/wg-ipv6-converter_{{ wireguard_ipv6_converter.setup.interface }}.service
|
||||||
|
register: serviceFile
|
||||||
|
|
||||||
|
- name: Enable service
|
||||||
|
ansible.builtin.service:
|
||||||
|
name: wg-ipv6-converter_{{ wireguard_ipv6_converter.setup.interface }}
|
||||||
|
daemon-reload: true
|
||||||
|
enabled: true
|
||||||
|
|
||||||
|
- name: Start service if interface exists already
|
||||||
|
ansible.builtin.service:
|
||||||
|
name: wg-ipv6-converter_{{ wireguard_ipv6_converter.setup.interface }}
|
||||||
|
state: "{{ 'restarted' if deployDownload.changed or serviceFile.changed else 'started' }}"
|
||||||
|
when: "wireguard_ipv6_converter.setup.interface in ansible_interfaces"
|
@ -0,0 +1,29 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=WireGuard IPv6 converter for {{ wireguard_ipv6_converter.setup.interface }}
|
||||||
|
{% if wireguard_ipv6_converter.service.bindTo is defined %}
|
||||||
|
BindsTo={{ wireguard_ipv6_converter.service.bindTo }}
|
||||||
|
After={{ wireguard_ipv6_converter.service.bindTo }}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=simple
|
||||||
|
{% if wireguard_ipv6_converter.service.bindTo is defined %}
|
||||||
|
ExecStartPre=/bin/sleep 10
|
||||||
|
{% endif %}
|
||||||
|
ExecStart=/usr/local/bin/wg-ipv6-converter
|
||||||
|
Restart=always
|
||||||
|
RestartSec=30
|
||||||
|
|
||||||
|
Environment="INTERFACE={{ wireguard_ipv6_converter.setup.interface }}"
|
||||||
|
{% if wireguard_ipv6_converter.setup.ipv6_format is defined %}
|
||||||
|
Environment="IPV6_FORMAT={{ wireguard_ipv6_converter.setup.ipv6_format }}"
|
||||||
|
{% endif %}
|
||||||
|
{% if wireguard_ipv6_converter.setup.filter_prefix is defined %}
|
||||||
|
Environment="FILTER_PREFIX={{ wireguard_ipv6_converter.setup.filter_prefix }}"
|
||||||
|
{% endif %}
|
||||||
|
{% if wireguard_ipv6_converter.setup.recheck_interval is defined %}
|
||||||
|
Environment="RECHECK_INTERVAL={{ wireguard_ipv6_converter.setup.recheck_interval }}"
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
Loading…
Reference in New Issue