Generate simple config
Some checks reported errors
continuous-integration/drone/push Build encountered an error

This commit is contained in:
Adrien Reslinger 2022-07-20 02:09:17 +02:00
parent 708147f415
commit dead47287a
Signed by: adrien
GPG key ID: DA7B27055C66D6DE
5 changed files with 54 additions and 33 deletions

View file

@ -5,4 +5,14 @@
- epel-release
- elrepo-release
state: present
update_cache: yes
update_cache: true
- name: Install kernel driver for WireGuard
package:
name:
- kmod-wireguard
state: present
update_cache: true
when:
- ansible_os_family == 'RedHat'
- ansible_distribution_major_version < "9"

View file

@ -12,9 +12,10 @@
- name: Install packages for WireGuard
package:
name: "{{ wireguard_packages }}"
name:
- "{{ wireguard_packages }}"
state: present
update_cache: yes
update_cache: true
- name: Configure wireguard
block:
@ -24,7 +25,8 @@
shell: >
cat /etc/wireguard/privatekey
register: wireguard_private_key
changed_when: no
changed_when: false
check_mode: false
rescue:
- name: Generate private key
shell: >
@ -44,7 +46,8 @@
shell: >
cat /etc/wireguard/publickey
register: wireguard_public_key
changed_when: no
changed_when: false
check_mode: false
rescue:
- name: Generate public key
shell: >
@ -58,28 +61,29 @@
group: root
mode: 0600
# - name: Set keys pair variable
# set_facts:
# wireguard_public_key: '{{ wireguard_public_key.stdout }}'
# wireguard_private_key: '{{ wireguard_private_key.stdout }}'
#
# - name: Install WireGuard configuration files
# template:
# src: "etc/wireguard/wireguard.conf.j2"
# dest: "/etc/wireguard/{{ wireguard_interface }}.conf"
# owner: root
# group: root
# mode: 0644
#
# - name: Enable Wireguard service
# service:
# name: "wg-quick@{{ wireguard_interface }}"
# enabled: yes
# state: restarted
# when:
# - skip_conf|false
# tags:
# - wireguard-conf
#
- name: Set keys pair variable
set_fact:
wireguard_public_key: '{{ wireguard_public_key.stdout }}'
wireguard_private_key: '{{ wireguard_private_key.stdout }}'
check_mode: false
- name: Install WireGuard configuration files
template:
src: "etc/wireguard/wireguard.conf.j2"
dest: "/etc/wireguard/{{ wireguard_interface }}.conf"
owner: root
group: root
mode: 0644
- name: Enable Wireguard service
service:
name: "wg-quick@{{ wireguard_interface }}"
enabled: true
state: restarted
when:
- not skip_conf
tags:
- wireguard-conf
tags:
- wireguard