machine_setup/ansible/roles/wireguard/tasks/freebsd.yaml
2022-12-03 17:16:37 -05:00

54 lines
1.3 KiB
YAML

- name: Install packages
package:
name:
- wireguard
state: present
- name: Configure wireguard
copy:
src: "{{ item }}"
dest: /usr/local/etc/wireguard/
mode: 0440
owner: root
group: root
with_fileglob: "files/wireguard_configs/{{ wireguard_directory }}/*.conf"
- name: Enable Wireguard
when: enabled_wireguard is defined
systemd:
enabled: yes
name: "wg-quick@{{ item }}"
daemon_reload: yes
loop: "{{ enabled_wireguard }}"
- name: Enable gateway
when: wireguard_gateway is defined and wireguard_gateway == true
community.general.sysrc:
name: "{{ item }}"
value: "YES"
path: /etc/rc.conf.d/routing
loop:
- gateway_enable
- ipv6_gateway_enable
- name: Enable wireguard service
when: enabled_wireguard is defined
community.general.sysrc:
name: wireguard_enable
value: "YES"
path: /etc/rc.conf.d/wireguard
- name: Disable wireguard service
when: enabled_wireguard is not defined
community.general.sysrc:
name: wireguard_enable
value: "NO"
path: /etc/rc.conf.d/wireguard
- name: Set enabled wireguard list
when: enabled_wireguard is defined
community.general.sysrc:
name: wireguard_interfaces
value: "{{ enabled_wireguard|join(' ') }}"
path: /etc/rc.conf.d/wireguard