-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
--- | ||
name: Test deployment | ||
'on': | ||
pull_request: | ||
push: | ||
schedule: | ||
# Run every Wednesday at 01:42 | ||
- cron: "42 1 * * 3" | ||
|
||
jobs: | ||
lint: | ||
name: Lint | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check out codebase | ||
uses: actions/checkout@v2 | ||
- name: Set up Python | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: '3.x' | ||
- name: Install dependencies | ||
run: pip3 install yamllint | ||
- name: Lint repository | ||
run: yamllint . |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
- name: Reconfigure the tunnel | ||
ansible.builtin.service: | ||
name: wg-quick@pdostal | ||
state: restarted |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
--- | ||
galaxy_info: | ||
role_name: wireguard | ||
namespace: pdostal | ||
author: Pavel Dostál | ||
description: Configurable wireguard host | ||
company: pdostal | ||
license: license MIT | ||
min_ansible_version: "2.9" | ||
platforms: | ||
- name: opensuse | ||
galaxy_tags: | ||
- wireguard | ||
dependencies: [] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
--- | ||
- name: Generate configuration file | ||
ansible.builtin.template: | ||
src: wireguard.j2 | ||
dest: "/etc/wireguard/pdostal.conf" | ||
owner: root | ||
group: root | ||
mode: '0700' | ||
- name: Do not count this as a failure | ||
ansible.builtin.command: "systemctl start wg-quick@pdostal" | ||
ignore_errors: yes | ||
Check warning on line 11 in tasks/configure.yml GitHub Actions / Lint
Check warning on line 11 in tasks/configure.yml GitHub Actions / Lint
Check warning on line 11 in tasks/configure.yml GitHub Actions / Lint
|
||
- name: Do not count this as a failure1 | ||
ansible.builtin.command: "journalctl --no-tail -u wg-quick@pdostal" | ||
register: journalctl | ||
ignore_errors: yes | ||
Check warning on line 15 in tasks/configure.yml GitHub Actions / Lint
Check warning on line 15 in tasks/configure.yml GitHub Actions / Lint
Check warning on line 15 in tasks/configure.yml GitHub Actions / Lint
|
||
- name: journalctl | ||
debug: | ||
var: journalctl.stdout_lines | ||
#notify: Reconfigure the tunnel | ||
Check warning on line 19 in tasks/configure.yml GitHub Actions / Lint
Check warning on line 19 in tasks/configure.yml GitHub Actions / Lint
Check warning on line 19 in tasks/configure.yml GitHub Actions / Lint
Check warning on line 19 in tasks/configure.yml GitHub Actions / Lint
Check warning on line 19 in tasks/configure.yml GitHub Actions / Lint
Check warning on line 19 in tasks/configure.yml GitHub Actions / Lint
Check warning on line 19 in tasks/configure.yml GitHub Actions / Lint
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
--- | ||
- ansible.builtin.import_tasks: prepare.yml | ||
- ansible.builtin.import_tasks: configure.yml |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
--- | ||
- name: Print some debug information | ||
vars: | ||
msg: | | ||
Ansible Distribution: {{ ansible_distribution }} | ||
Ansible Dist version: {{ ansible_distribution_version }} | ||
Ansible OS family: {{ ansible_os_family }} | ||
debug: | ||
msg: "{{ msg.split('\n') }}" | ||
- name: Install latest version on Archlinux | ||
community.general.pacman: | ||
name: | ||
- wireguard-tools | ||
state: present | ||
when: ansible_distribution == 'Archlinux' | ||
|
||
- name: Install latest version on Debian | ||
ansible.builtin.apt: | ||
name: wireguard | ||
state: present | ||
when: ansible_distribution == 'Debian' | ||
|
||
- name: Install latest version on openSUSE | ||
community.general.zypper: | ||
name: wireguard-tools | ||
state: present | ||
when: ansible_os_family == "Suse" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
[Interface] | ||
Address = {{ address }} | ||
ListenPort = 51871 | ||
PrivateKey = {{ private_key }} | ||
|
||
{% for host in groups['all'] %} | ||
{% if hostvars[host]['inventory_hostname'] != inventory_hostname %} | ||
[Peer] | ||
# {{ hostvars[host]['inventory_hostname'] }} | ||
PublicKey = {{ hostvars[host]['public_key'] }} | ||
AllowedIPs = {{ hostvars[host]['allowed_ips'] }} | ||
{% if hostvars[host]['endpoint'] is defined %} | ||
Endpoint = {{ hostvars[host]['endpoint'] }} | ||
{% endif %} | ||
PersistentKeepalive = 25 | ||
|
||
{% endif %} | ||
{% endfor %} | ||
|