add wireguard role

This commit is contained in:
2022-08-30 07:51:47 -05:00
parent 2b6b7aca79
commit 0760ae4c2c
10 changed files with 158 additions and 0 deletions

View File

@@ -0,0 +1,15 @@
---
- name: configure interface
template:
src: wg-multi.conf.j2
dest: "{{ wireguard_etc_path }}/{{ _wireguard_interface }}.conf"
owner: root
group: root
mode: 0400
notify: restart wg-quick
- name: manage service
service:
name: "{{ wireguard_service_name }}@{{ _wireguard_interface }}"
state: "{{ wireguard_service_state }}"
enabled: "{{ wireguard_service_enabled }}"

View File

@@ -0,0 +1 @@
---

View File

View File

@@ -0,0 +1,5 @@
---
- name: install package
package:
name: "{{ wireguard_package_name }}"
state: "{{ wireguard_package_state }}"

View File

@@ -0,0 +1,36 @@
---
- name: gather os specific variables
include_vars: "{{ lookup('first_found', possible_files) }}"
vars:
possible_files:
files:
- "{{ ansible_distribution }}-{{ ansible_distribution_version }}.yaml"
- "{{ ansible_distribution }}.yaml"
- "{{ ansible_os_family }}.yaml"
- "default.yaml"
paths:
- vars
- name: include os specific tasks
include_tasks: "{{ lookup('first_found', possible_files) }}"
vars:
possible_files:
files:
- "{{ ansible_distribution }}-{{ ansible_distribution_version }}.yaml"
- "{{ ansible_distribution }}.yaml"
- "{{ ansible_os_family }}.yaml"
- "default.yaml"
paths:
- tasks
- include: install.yaml
#- include: configure.yaml
- include: configure-interface.yaml
loop: "{{ wireguard_interfaces.keys() | list }}"
loop_control:
loop_var: _wireguard_interface
when:
- wireguard_interfaces is mapping
- wireguard_interfaces.keys() | length