MEschenbacher's Wireguard Saltstack Formula
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

пре 6 година
1234567891011121314151617181920212223242526272829303132333435
  1. {% from "wireguard/map.jinja" import wireguard with context %}
  2. wireguard:
  3. pkg.installed:
  4. - name: {{ wireguard.package }}
  5. {% for name, values in salt['pillar.get']('wireguard:interfaces', {}).items() %}
  6. wireguard_{{ name }}:
  7. wg.present:
  8. - name: {{ name }}
  9. {% for k, v in values.items() %}
  10. - {{k}}: {{v}}
  11. {% endfor %}
  12. {% endfor %}
  13. {% for interface, peerlist in salt['pillar.get']('wireguard:peers', {}).items() %}
  14. {% for peer in peerlist %}
  15. wireguard_{{ interface }}_peer_{{ peer.get('peer') }}:
  16. wg.peer_present:
  17. - interface: {{ interface }}
  18. - name: {{ peer.get('peer') }}
  19. {% if peer.get('endpoint') != None %}
  20. - endpoint: {{ peer.get('endpoint') }}
  21. {% endif %}
  22. {% if peer.get('persistent_keepalive') != None %}
  23. - persistent_keepalive: {{ peer.get('persistent_keepalive') }}
  24. {% endif %}
  25. {% if peer.get('allowed_ips') != None %}
  26. - allowed_ips:
  27. {% for subnet in peer.get('allowed_ips', []) %}
  28. - {{subnet}}
  29. {% endfor %}
  30. {% endif %}
  31. {% endfor %}
  32. {% endfor %}