Skip to content

Commit dd97ca4

Browse files
authored
feat(wireguard): add util to print configs (#27)
1 parent 6364edd commit dd97ca4

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

tasks/deploy_wireguard.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,4 +107,12 @@
107107
wait_timeout: "{{ infra_compose_wait_timeout }}"
108108
register: deploy_wireguard_services_output
109109

110+
- name: Copy print-qr-codes util script into place
111+
ansible.builtin.template:
112+
src: print-qr-codes.sh.j2
113+
dest: "{{ infra_wireguard_directory_path }}/print-qr-codes.sh"
114+
owner: "{{ infra_wireguard_directory_owner }}"
115+
group: "{{ infra_wireguard_directory_group }}"
116+
mode: "0750"
117+
110118
...

templates/print-qr-codes.sh.j2

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#! /usr/bin/env bash
2+
3+
# util to print QR codes for wireguard configs
4+
# requires 'jq' and 'qrencode' to be installed
5+
6+
if ! command -v jq &> /dev/null; then
7+
echo "Missing required package 'jq'"
8+
exit 1
9+
elif ! command -v qrencode &> /dev/null; then
10+
echo "Missing required package 'qrencode'"
11+
exit 1
12+
fi
13+
14+
for wgcfg in $(docker volume inspect {{ infra_wireguard_volume_name_config }} | jq '.[].Mountpoint' | sed 's/"//g')/peer_*/peer_*.conf; do
15+
echo $(basename "$wgcfg")
16+
qrencode -t ansiutf8 < "$wgcfg"
17+
done

0 commit comments

Comments
 (0)