f
This commit is contained in:
parent
dda0d457e1
commit
6db5b9d2b8
3 changed files with 41 additions and 0 deletions
11
roles/mgrote_wireguard/defaults/main.yml
Normal file
11
roles/mgrote_wireguard/defaults/main.yml
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
---
|
||||||
|
wireguard_conf_dir: /etc/wireguard
|
||||||
|
#wireguard_profiles:
|
||||||
|
# - name: wg0
|
||||||
|
# privatekey:
|
||||||
|
# address:
|
||||||
|
# dns:
|
||||||
|
# publickey:
|
||||||
|
# allowedips:
|
||||||
|
# endpoint:
|
||||||
|
...
|
20
roles/mgrote_wireguard/tasks/main.yml
Normal file
20
roles/mgrote_wireguard/tasks/main.yml
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
---
|
||||||
|
- name: Ensure package exists
|
||||||
|
become: true
|
||||||
|
ansible.builtin.package:
|
||||||
|
name:
|
||||||
|
- wireguard
|
||||||
|
state: present
|
||||||
|
|
||||||
|
- name: Ensure profiles are templated
|
||||||
|
become: true
|
||||||
|
ansible.builtin.template:
|
||||||
|
src: "wg.conf.j2"
|
||||||
|
dest: "{{ wireguard_conf_dir }}/{{ item.name }}.conf"
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: "0600"
|
||||||
|
when:
|
||||||
|
- wireguard_profiles is defined
|
||||||
|
loop: wireguard_profiles
|
||||||
|
...
|
10
roles/mgrote_wireguard/templates/wg.conf.j2
Normal file
10
roles/mgrote_wireguard/templates/wg.conf.j2
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
[Interface]
|
||||||
|
PrivateKey = {{ privatekey }}
|
||||||
|
Address = {{ address }}
|
||||||
|
DNS = {{ dns }}
|
||||||
|
|
||||||
|
[Peer]
|
||||||
|
PublicKey = {{ publickey }}
|
||||||
|
AllowedIPs = {{ allowedips }}
|
||||||
|
Endpoint = {{ endpoint }}
|
||||||
|
PersistentKeepalive = 25
|
Loading…
Reference in a new issue