MEschenbacher's Wireguard Saltstack Formula
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

6 年前
123456789101112131415161718192021
  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 %}