This repository has been archived on 2023-12-29. You can view files and clone it, but cannot push or open issues or pull requests.
pi-ansible/roles/docker_services/tasks/services/wireguard.yml
2023-04-21 00:29:19 +02:00

40 lines
1.1 KiB
YAML

# vim: ft=yaml.ansible
---
- name: Create Wireguard volume directory
ansible.builtin.file:
name: "{{ services.wireguard.volume }}"
owner: '911'
mode: u=rwx,g=rx,o=rx
state: directory
- name: Create Docker network for Wireguard
community.docker.docker_network:
name: wireguard
state: present
- name: Deploy Wireguard Docker container
community.docker.docker_container:
name: wireguard
state: "{{ 'absent' if stop is defined and stop else 'started' }}"
restart: "{{ stop is undefined or not stop }}"
image: linuxserver/wireguard:{{ services.wireguard.version }}
restart_policy: always
networks:
- name: wireguard
env:
SERVERURL: "{{ services.wireguard.domain }}"
SERVERPORT: '51820'
PEERS: "{{ secrets.wireguard.peers }}"
PEERDNS: auto
TZ: "{{ timezone }}"
volumes:
- "{{ services.wireguard.volume }}:/config:rw"
- /lib/modules:/lib/modules:rw
published_ports:
- 51820:51820/udp
capabilities:
- net_admin
- sys_module
sysctls:
net.ipv4.conf.all.src_valid_mark: 1