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.

22 lines
622B

  1. {%- for interface in salt['pillar.get']('wireguard', {}).keys() %}
  2. wireguard_interface_{{interface}}:
  3. file.managed:
  4. - name: /etc/wireguard/{{interface}}.conf
  5. - contents_pillar: wireguard:{{interface}}:config
  6. - mode: 640
  7. {% if salt['pillar.get']('wireguard:' ~ interface ~ ':enable', True) %}
  8. restart wg-quick@{{interface}}:
  9. service.running:
  10. - name: wg-quick@{{interface}}
  11. - enable: True
  12. - watch:
  13. - file: wireguard_interface_{{interface}}
  14. {% else %}
  15. stop and disable wg-quick@{{interface}}:
  16. service.dead:
  17. - name: wg-quick@{{interface}}
  18. - enable: False
  19. {% endif %}
  20. {%- endfor %}