-
Notifications
You must be signed in to change notification settings - Fork 0
/
wireguard.yml
74 lines (63 loc) · 1.99 KB
/
wireguard.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
---
- hosts: all
become: true
tasks:
- name: Add an apt key by id from a keyserver
shell: 'wget -q "https://keyserver.ubuntu.com/pks/lookup?op=get&search=0xE1B39B6EF6DDB96564797591AE33835F504A1A25" -O- | gpg --dearmor > /etc/apt/trusted.gpg.d/wireguard.gpg'
- name: Add ppa Wireguard
apt_repository:
repo: 'deb http://ppa.launchpad.net/wireguard/wireguard/ubuntu xenial main'
- name: Install Wireguard
apt:
name: wireguard-dkms
update_cache: yes
state: present
- name: Install Wireguard
package:
name: "{{ item }}"
state: present
loop:
- wireguard-tools
- qrencode
- name: Generate private keys
shell: wg genkey
register: wireguard_genkey
- name: Generate private client keys
shell: wg genkey
register: client_private
- name: Generate public keys
shell: "echo {{ client_private.stdout }} | wg pubkey"
register: client_public
- set_fact:
private_key: "{{ wireguard_genkey.stdout }}"
- name: Generate public keys
shell: "echo {{ private_key }} | wg pubkey"
register: wireguard_pubkey
- set_fact:
public_key: "{{ wireguard_pubkey.stdout }}"
- name: Configure wireguard
template:
src: wireguard.conf.j2
dest: /etc/wireguard/wireguard.conf
loop:
- name: Configure client config
template:
src: client.conf.j2
dest: /opt/client.conf
- name: Configure interfaces
template:
src: wireguard_interface.j2
dest: /etc/network/interfaces.d/wireguard
- name: run my script!
command: qrencode -t ansiutf8 < /opt/client.conf
register: qrcode
- pause:
prompt: "{{ qrcode.stdout }}"
- name: run my script!
command: "qrencode -s 10 -m 10 -t png < /opt/client.conf -o /opt/code.png"
- fetch:
src: /opt/code.png
dest: code.png
flat: yes
# - name: Running
#create qrcode