blob: 6ef15ea915516a015c6d77bd445ed13cacd8ce2c (
plain) (
tree)
|
|
---
- name: create wireguard directory
ansible.builtin.file:
path: "{{ wireguard__dir }}"
owner: 0
group: 0
mode: "0700"
state: directory
- name: include local tasks
ansible.builtin.include_tasks: local.yml
run_once: true
args:
apply:
delegate_to: localhost
- name: copy wireguard configuration
ansible.builtin.copy:
src: "{{ wireguard__local_dir }}/{{ wireguard__local_configuration }}"
dest: "{{ wireguard__dir }}/{{ wireguard__interface_name }}.conf"
owner: 0
group: 0
mode: "0600"
- name: install wireguard
ansible.builtin.package:
name: wireguard-tools
state: present
- name: enable wireguard interface
ansible.builtin.lineinfile:
path: /etc/rc.local
regexp: "^/usr/local/bin/wg-quick up {{ wireguard__interface_name }}$"
line: "/usr/local/bin/wg-quick up {{ wireguard__interface_name }}"
owner: 0
create: true
mode: "0644"
- name: restart wireguard interface
ansible.builtin.raw: |
wg-quick down {{ wireguard__interface_name }}
sleep {{ 10 | random(start=1) }}
wg-quick up {{ wireguard__interface_name }}
register: wireguard__result_status
- name: add cronjob for keepalive
ansible.builtin.cron:
name: keepalive network traffic to domain controller
job: "! ping -c 1 -w 1 {{ hostvars[wireguard__domain_controller].__ip.internal }} && /usr/local/bin/wg-quick down {{ wireguard__interface_name }} && /usr/local/bin/wg-quick up {{ wireguard__interface_name }}"
- name: show wireguard output
ansible.builtin.debug:
var: wireguard__result_status.stdout
|