MEschenbacher's Wireguard Saltstack Formula
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

init.sls 1.3KB

6 lat temu
6 lat temu
6 lat temu
6 lat temu
6 lat temu
6 lat temu
6 lat temu
6 lat temu
6 lat temu
123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. {% from "wireguard/map.jinja" import wireguard with context %}
  2. {% for interface, values in salt['pillar.get']('wireguard:interfaces', {}).items() %}
  3. wireguard_{{ interface }}:
  4. wg.present:
  5. - name: {{ interface }}
  6. {% for k, v in values.items() %}
  7. {% if k in ['listen_port', 'fwmark', 'private_key'] %}
  8. - {{k}}: {{v}}
  9. {% endif %}
  10. {% endfor %} {# values.items() #}
  11. {% for peer in values.get('peers', {}) %}
  12. wireguard_{{ interface }}_peer_{{ peer.get('peer') }}:
  13. wg.peer_present:
  14. - interface: {{ interface }}
  15. - name: {{ peer.get('peer') }}
  16. {% if peer.get('endpoint') != None %}
  17. - endpoint: '{{ peer.get('endpoint') }}'
  18. {% endif %}
  19. {% if peer.get('persistent_keepalive') != None %}
  20. - persistent_keepalive: {{ peer.get('persistent_keepalive') }}
  21. {% endif %}
  22. {% if peer.get('allowed_ips') != None %}
  23. - allowed_ips:
  24. {% for subnet in peer.get('allowed_ips', []) %}
  25. - {{subnet}}
  26. {% endfor %}
  27. {% if peer.get('preshared_key') != None %}
  28. - preshared_key: {{ peer.get('preshared_key') }}
  29. {% endif %}
  30. {% endif %}
  31. {% endfor %}
  32. {% endfor %}
  33. {% for interface in salt['pillar.get']('wireguard:set_forward_interfaces', []) %}
  34. net.ipv4.conf.{{interface}}.forwarding:
  35. sysctl.present:
  36. - value: 1
  37. net.ipv6.conf.{{interface}}.forwarding:
  38. sysctl.present:
  39. - value: 1
  40. {% endfor %}