add wireguard role
This commit is contained in:
15
roles/wireguard/tasks/configure-interface.yaml
Normal file
15
roles/wireguard/tasks/configure-interface.yaml
Normal 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 }}"
|
1
roles/wireguard/tasks/configure.yaml
Normal file
1
roles/wireguard/tasks/configure.yaml
Normal file
@@ -0,0 +1 @@
|
||||
---
|
0
roles/wireguard/tasks/default.yaml
Normal file
0
roles/wireguard/tasks/default.yaml
Normal file
5
roles/wireguard/tasks/install.yaml
Normal file
5
roles/wireguard/tasks/install.yaml
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
- name: install package
|
||||
package:
|
||||
name: "{{ wireguard_package_name }}"
|
||||
state: "{{ wireguard_package_state }}"
|
36
roles/wireguard/tasks/main.yaml
Normal file
36
roles/wireguard/tasks/main.yaml
Normal 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
|
Reference in New Issue
Block a user