chore: ansible-lint
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
---
|
||||
wireguard_primary_interface: "{{ network_interfaces.0.name }}"
|
||||
wireguard_port: 51820 # static port to receive input connections
|
||||
wireguard_server_mode: true # enables NAT and open port
|
||||
|
||||
@@ -1,58 +1,59 @@
|
||||
- name: install wireguard
|
||||
package:
|
||||
---
|
||||
- name: Install wireguard
|
||||
ansible.builtin.package:
|
||||
name: "{{ (ansible_facts['os_family'] == 'Archlinux') | ternary('wireguard-tools', 'wireguard') }}"
|
||||
state: present
|
||||
|
||||
# to support "DNS=" if used in a "client way"
|
||||
- name: install openresolv/resolveconf
|
||||
package:
|
||||
- name: Install openresolv/resolveconf
|
||||
ansible.builtin.package:
|
||||
name: "{{ (ansible_facts['os_family'] == 'Archlinux') | ternary('openresolv', 'resolvconf') }}"
|
||||
state: present
|
||||
|
||||
- name: ensure wireguard configuration is only owned by root
|
||||
file:
|
||||
- name: Ensure wireguard configuration is only owned by root
|
||||
ansible.builtin.file:
|
||||
path: "{{ wireguard_config_base_path }}"
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0700
|
||||
recurse: yes
|
||||
mode: "0700"
|
||||
recurse: true
|
||||
|
||||
- name: check if private key exists
|
||||
stat:
|
||||
- name: Check if private key exists
|
||||
ansible.builtin.stat:
|
||||
path: "{{ wireguard_config_base_path }}/privatekey"
|
||||
register: pkey_file
|
||||
|
||||
- name: generate wireguard keys if not present
|
||||
shell: wg genkey | tee {{ wireguard_config_base_path }}/privatekey | wg pubkey > {{ wireguard_config_base_path }}/publickey
|
||||
- name: Generate wireguard keys if not present
|
||||
ansible.builtin.shell: wg genkey | tee {{ wireguard_config_base_path }}/privatekey | wg pubkey > {{ wireguard_config_base_path }}/publickey
|
||||
when: not pkey_file.stat.exists
|
||||
|
||||
- name: retrieve wireguard private key from file
|
||||
slurp:
|
||||
- name: Retrieve wireguard private key from file
|
||||
ansible.builtin.slurp:
|
||||
src: "{{ wireguard_config_base_path }}/privatekey"
|
||||
register: private_key
|
||||
|
||||
- name: set wireguard private key
|
||||
set_fact:
|
||||
- name: Set wireguard private key
|
||||
ansible.builtin.set_fact:
|
||||
wireguard_private_key: "{{ private_key['content'] | b64decode }}"
|
||||
|
||||
- name: disable "dns=" instruction if unbound is used to avoid race conditions at startup
|
||||
set_fact:
|
||||
- name: Disable "dns=" instruction if unbound is used to avoid race conditions at startup
|
||||
ansible.builtin.set_fact:
|
||||
wireguard_dns:
|
||||
when: unbound_custom_lan_records is defined
|
||||
|
||||
- name: install wireguard config
|
||||
template:
|
||||
- name: Install wireguard config
|
||||
ansible.builtin.template:
|
||||
src: wireguard.conf.j2
|
||||
dest: /etc/wireguard/{{ wireguard_interface }}.conf
|
||||
|
||||
- name: start and enable service
|
||||
service:
|
||||
- name: Start and enable service
|
||||
ansible.builtin.service:
|
||||
name: wg-quick@{{ wireguard_interface }}
|
||||
state: started
|
||||
enabled: yes
|
||||
daemon_reload: yes
|
||||
enabled: true
|
||||
daemon_reload: true
|
||||
|
||||
- name: configure the firewall for wireguard
|
||||
- name: Configure the firewall for wireguard
|
||||
community.general.ufw:
|
||||
rule: allow
|
||||
port: "{{ wireguard_port }}"
|
||||
|
||||
Reference in New Issue
Block a user