3
0
Fork 0

Compare commits

...

13 Commits

Author SHA1 Message Date
KemoNine 53efc122e3 Add note about fork 2020-08-04 22:01:34 +00:00
KemoNine 0217d41830 Add s6-svc restart for containers 2020-08-04 20:26:38 +00:00
KemoNine ef8de286b1 Started work on s6-svc restart of wireguard for containerized deployment(s) 2020-08-04 19:27:15 +00:00
KemoNine fbc79beb72 remove unnecessary whitespace from wg.conf template 2020-08-04 19:26:58 +00:00
KemoNine d1ed058fa8 Tweak default variable 2020-08-04 18:42:30 +00:00
KemoNine d00bcb7d6a Add missing default variable 2020-08-04 18:37:51 +00:00
KemoNine 0afb85375e Add containerization skips 2020-08-04 17:49:30 +00:00
KemoNine 1faf8d9f12 Attempt to tweak config generator to include ALL hosts that could have been included in the play, rather than just the ones matching filters (helpful for controller deployments) 2020-08-04 17:39:33 +00:00
KemoNine 8fc7870c76 Tweak wireguard role to ensure the bare-metal tasks can be skipped 2020-08-04 06:37:03 +00:00
Robert Wimmer d5b81cb75e
update CHANGELOG (#57)
Co-authored-by: githubixx <home@tauceti.net>
2020-06-14 17:56:46 +02:00
pallinger 1997b9d710
Fix on debian openstack images (#55)
* on openstack Debian images, the kernel is different, so we need to install different kernel headers, too

* fix syntax error in conditional fact

* remove debug message

Co-authored-by: Peter Pallinger <pallinger@sztaki.hu>
2020-06-14 17:52:17 +02:00
Robert Wimmer 359d601008
update CHANGELOG for version 6.3.0 (#56)
Co-authored-by: githubixx <home@tauceti.net>
2020-06-04 23:22:47 +02:00
Stefan Haun 2ef11ac648
Add a role for Raspbian (#54)
* Rename debian-setup role to point to vanilla Debian

* Add a specific setup role for Raspbian

This role will fail for now, Raspbian is not supported by this role as it is.

* Add a switch for Raspbian

* Add Raspbian role for installing WireGuard

* Raspbian: Handle reboot with molly-guard and older Ansible versions
2020-06-04 23:17:25 +02:00
9 changed files with 185 additions and 61 deletions

View File

@ -1,6 +1,14 @@
Changelog
---------
**6.3.1**
- Support Openstack Debian images (contribution by @pallinger)
**6.3.0**
- Support Raspbian (contribution by @penguineer)
**6.2.0**
- Support Ubuntu 20.04 (Focal Fossa)

View File

@ -1,3 +1,5 @@
# Fork of https://github.com/githubixx/ansible-role-wireguard.git with some minor tweaks to ensure PiFrameFleet can be provisioned properly
ansible-role-wireguard
======================

View File

@ -12,6 +12,9 @@ wireguard_port: "51820"
# The default interface name that wireguard should use if not specified otherwise.
wireguard_interface: "wg0"
# Whether or not WireGuard is running in a container
wireguard_containerized: false
#######################################
# Settings only relevant for Ubuntu

View File

@ -6,7 +6,7 @@
loop:
- stopped
- started
when: not wg_syncconf
when: not wg_syncconf and not wireguard_containerized
listen: "reconfigure wireguard"
- name: syncconf wireguard
@ -19,5 +19,10 @@
exit 0
args:
executable: "/bin/bash"
when: wg_syncconf
when: wg_syncconf and not wireguard_containerized
listen: "reconfigure wireguard"
- name: restart wireguard (container)
command: /usr/bin/s6-svc -r /var/run/s6/services/wireguard
when: wireguard_containerized
listen: "reconfigure wireguard"

View File

@ -3,6 +3,7 @@
setup:
- include_tasks: "setup-{{ ansible_distribution|lower }}.yml"
when: not wireguard_containerized
- name: Enable WireGuard kernel module
modprobe:
@ -129,3 +130,4 @@
name: "wg-quick@{{ wireguard_interface }}"
state: started
enabled: yes
when: not wireguard_containerized

View File

@ -0,0 +1,93 @@
---
- name: (Raspbian) Install GPG - required to add wireguard key
apt:
name: gnupg
state: present
- name: (Raspbian) Add Debian repository key
apt_key:
keyserver: "keyserver.ubuntu.com"
id: "04EE7237B7D453EC"
state: present
when: ansible_lsb.id == "Raspbian"
tags:
- wg-install
- name: (Raspbian) Add Debian Unstable repository for WireGuard
apt_repository:
repo: "deb http://deb.debian.org/debian unstable main"
state: present
update_cache: yes
tags:
- wg-install
- name: (Raspbian) Install latest kernel
apt:
name:
- "raspberrypi-kernel"
state: latest
register: kernel_update
tags:
- wg-install
- name: (Raspbian) Reboot after kernel update (Ansible >= 2.8)
reboot:
search_paths: ['/lib/molly-guard', '/usr/sbin']
when:
- ansible_version.full is version('2.8.0', '>=')
- kernel_update is changed
tags:
- wg-install
- name: (Raspbian) Check if molly-guard is installed (Ansible < 2.8)
stat:
path: /lib/molly-guard/
register: molly_guard
- name: (Raspbian) Reboot after kernel update (Ansible < 2.8, no molly-guard)
reboot:
when:
- ansible_version.full is version('2.8.0', '<')
- kernel_update is changed
- not molly_guard.stat.exists
tags:
- wg-install
- name: (Raspbian) Reboot after kernel update (Ansible < 2.8, with molly-guard)
command: /lib/molly-guard/shutdown -r now
async: 1
poll: 0
ignore_unreachable: yes
when:
- ansible_version.full is version('2.8.0', '<')
- kernel_update is changed
- molly_guard.stat.exists
tags:
- wg-install
- name: (Raspbian) Waiting for host to be available (Ansible < 2.8, with molly-guard)
wait_for_connection:
when:
- ansible_version.full is version('2.8.0', '<')
- kernel_update is changed
- molly_guard.stat.exists
tags:
- wg-install
- name: (Raspbian) Install latest kernel headers to compile Wireguard with DKMS
apt:
name:
- "raspberrypi-kernel-headers"
state: latest
tags:
- wg-install
- name: (Raspbian) Install wireguard packages
apt:
name:
- "wireguard-dkms"
- "wireguard-tools"
state: present
tags:
- wg-install

View File

@ -0,0 +1,37 @@
---
- name: (Debian) Install GPG - required to add wireguard key
apt:
name: gnupg
state: present
- name: (Debian) Add WireGuard repository on buster or earlier
apt_repository:
repo: "deb http://deb.debian.org/debian buster-backports main"
state: present
update_cache: yes
when: ansible_distribution_version | int <= 10
tags:
- wg-install
- name: (Debian) Get architecture
command: "dpkg --print-architecture"
register: dpkg_arch
changed_when: False
- set_fact:
kernel_header_version: "{{ ('-cloud-' in ansible_kernel) | ternary(ansible_kernel,dpkg_arch.stdout) }}"
- name: (Debian) Install kernel headers to compile Wireguard with DKMS
apt:
name:
- "linux-headers-{{ kernel_header_version }}"
state: present
- name: (Debian) Install wireguard packages
apt:
name:
- "wireguard-dkms"
- "wireguard-tools"
state: present
tags:
- wg-install

View File

@ -1,34 +1,8 @@
---
- name: (Debian) Install GPG - required to add wireguard key
apt:
name: gnupg
state: present
- name: (Debian) Add WireGuard repository on buster or earlier
apt_repository:
repo: "deb http://deb.debian.org/debian buster-backports main"
state: present
update_cache: yes
when: ansible_distribution_version | int <= 10
tags:
- wg-install
- include_tasks: "setup-debian-raspbian.yml"
when: ansible_lsb.id == "Raspbian"
register: raspbian_setup
- name: (Debian) Get architecture
command: "dpkg --print-architecture"
register: dpkg_arch
changed_when: False
- name: (Debian) Install kernel headers to compile Wireguard with DKMS
apt:
name:
- "linux-headers-{{ dpkg_arch.stdout }}"
state: present
- name: (Debian) Install wireguard packages
apt:
name:
- "wireguard-dkms"
- "wireguard-tools"
state: present
tags:
- wg-install
- include_tasks: "setup-debian-vanilla.yml"
when: raspbian_setup is skipped

View File

@ -39,32 +39,32 @@ PostDown = {{ wg_postdown }}
{% if hostvars[inventory_hostname].wireguard_save_config is defined %}
SaveConfig = true
{% endif %}
{% for host in ansible_play_hosts %}
{% if host != inventory_hostname %}
[Peer]
# {{ host }}
PublicKey = {{hostvars[host].public_key}}
{% if hostvars[host].wireguard_allowed_ips is defined %}
AllowedIPs = {{hostvars[host].wireguard_allowed_ips}}
{% else %}
AllowedIPs = {{hostvars[host].wireguard_ip}}/32
{% endif %}
{% if hostvars[host].wireguard_persistent_keepalive is defined %}
PersistentKeepalive = {{hostvars[host].wireguard_persistent_keepalive}}
{% endif %}
{% if hostvars[host].wireguard_port is defined and hostvars[host].wireguard_port is number %}
{% if hostvars[host].wireguard_endpoint is defined and hostvars[host].wireguard_endpoint != "" %}
Endpoint = {{hostvars[host].wireguard_endpoint}}:{{hostvars[host].wireguard_port}}
{% else %}
Endpoint = {{host}}:{{hostvars[host].wireguard_port}}
{% endif %}
{% elif hostvars[host].wireguard_endpoint is defined and hostvars[host].wireguard_endpoint != "" %}
Endpoint = {{hostvars[host].wireguard_endpoint}}:{{wireguard_port}}
{% elif hostvars[host].wireguard_endpoint == "" %}
# No endpoint defined for this peer
{% else %}
Endpoint = {{host}}:{{wireguard_port}}
{% endif %}
{% endif %}
{% for host in ansible_play_hosts_all %}
{% if host != inventory_hostname %}
[Peer]
# {{ host }}
PublicKey = {{hostvars[host].public_key}}
{% if hostvars[host].wireguard_allowed_ips is defined %}
AllowedIPs = {{hostvars[host].wireguard_allowed_ips}}
{% else %}
AllowedIPs = {{hostvars[host].wireguard_ip}}/32
{% endif %}
{% if hostvars[host].wireguard_persistent_keepalive is defined %}
PersistentKeepalive = {{hostvars[host].wireguard_persistent_keepalive}}
{% endif %}
{% if hostvars[host].wireguard_port is defined and hostvars[host].wireguard_port is number %}
{% if hostvars[host].wireguard_endpoint is defined and hostvars[host].wireguard_endpoint != "" %}
Endpoint = {{hostvars[host].wireguard_endpoint}}:{{hostvars[host].wireguard_port}}
{% else %}
Endpoint = {{host}}:{{hostvars[host].wireguard_port}}
{% endif %}
{% elif hostvars[host].wireguard_endpoint is defined and hostvars[host].wireguard_endpoint != "" %}
Endpoint = {{hostvars[host].wireguard_endpoint}}:{{wireguard_port}}
{% elif hostvars[host].wireguard_endpoint == "" %}
# No endpoint defined for this peer
{% else %}
Endpoint = {{host}}:{{wireguard_port}}
{% endif %}
{% endif %}
{% endfor %}