tlu/salt/states/wireguard/init.sls

27 lines
749 B
Plaintext
Raw Permalink Normal View History

2021-10-12 13:00:09 +00:00
Install wireguard tools:
pkg.installed:
- name: wireguard-tools
{% if pillar['wireguard']['privatekey'] %}
configure wireguard interface:
file.managed:
- name: /etc/wireguard/{{ pillar['wireguard']['iface'] }}.conf
- source: salt://wireguard/files/interface.conf.template
- template: jinja
- user: root
- group: root
- mode: "0600"
stop wireguard interface:
cmd.run:
- name: wg-quick down {{ pillar['wireguard']['iface'] }}
- onlyif: wg show {{ pillar['wireguard']['iface'] }}
- onchanges:
- file: configure wireguard interface
start wireguard interface:
cmd.run:
- name: wg-quick up {{ pillar['wireguard']['iface'] }}
- unless: wg show {{ pillar['wireguard']['iface'] }}
{% endif %}