Przeglądaj źródła

Wireguard: Reflect data structure changes

Signed-off-by: Maximilian Wilhelm <max@sdn.clinic>
Maximilian Wilhelm 2 lat temu
rodzic
commit
4c2f0c4408
2 zmienionych plików z 4 dodań i 3 usunięć
  1. 3 2
      wireguard/init.sls
  2. 1 1
      wireguard/wireguard.conf.tmpl

+ 3 - 2
wireguard/init.sls

@@ -1,7 +1,7 @@
 #
 # Wireguard VPNs
 #
-{% set tunnels = salt['pillar.get']('nodes:' ~ grains.id ~ ':wireguard', {}) %}
+{% set wg_cfg = salt['pillar.get']('nodes:' ~ grains.id ~ ':wireguard', {}) %}
 
 
 include:
@@ -24,13 +24,14 @@ Cleanup /etc/wireguard:
     - clean: true
     # Add cleanup action for active tunnels
 
-{% for iface, tunnel_config in tunnels.items () %}
+{% for iface, tunnel_config in wg_cfg.get ('tunnels', {}).items () %}
 /etc/wireguard/{{ iface }}.conf:
   file.managed:
     - source: salt://wireguard/wireguard.conf.tmpl
     - template: jinja
     - context:
       config: {{ tunnel_config }}
+      privkey: {{ wg_cfg.get ('privkey') }}
     - require:
       - file: Create /etc/wireguard
     - require_in:

+ 1 - 1
wireguard/wireguard.conf.tmpl

@@ -2,7 +2,7 @@
 # Wireguard tunnel to {{ config['peer_fqdn'] }} (Salt managed)
 #
 [Interface]
-PrivateKey = {{ config['local_privkey'] }}
+PrivateKey = {{ privkey }}
 {%- if config['mode'] == 'server' %}
 ListenPort = {{ config['port'] }}
 {%- endif %}