Compare commits

...

No commits in common. "main" and "docs" have entirely different histories.
main ... docs

21 changed files with 8 additions and 464 deletions

11
.gitignore vendored
View File

@ -1,11 +0,0 @@
# ---> Ansible
*.retry
plugins
library
# ---> Python
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

View File

@ -1,15 +0,0 @@
---
ansible:
custom_modules:
- iptables_raw
- openssl_pkcs12
- proxmox_kvm
- ucr
- corenetworks_dns
- corenetworks_token
rules:
exclude_files:
- "LICENSE*"
- "**/*.md"
- "**/*.ini"

View File

@ -1,7 +0,0 @@
---
default: True
MD013: False
MD041: False
MD024: False
MD004:
style: dash

View File

@ -1 +0,0 @@
LICENSE

View File

@ -1,47 +0,0 @@
---
when:
- event: [pull_request]
- event: [push, manual]
branch:
- ${CI_REPO_DEFAULT_BRANCH}
steps:
- name: generate
image: quay.io/thegeeklab/ansible-doctor
environment:
ANSIBLE_DOCTOR_EXCLUDE_FILES: molecule/
ANSIBLE_DOCTOR_FORCE_OVERWRITE: "true"
ANSIBLE_DOCTOR_LOG_LEVEL: INFO
ANSIBLE_DOCTOR_ROLE_NAME: ${CI_REPO_NAME}
ANSIBLE_DOCTOR_TEMPLATE: readme
- name: format
image: quay.io/thegeeklab/alpine-tools
commands:
- prettier -w README.md
- name: diff
image: quay.io/thegeeklab/alpine-tools
commands:
- git diff --color=always README.md
- name: publish
image: quay.io/thegeeklab/wp-git-action
settings:
action:
- commit
- push
author_email: ci-bot@rknet.org
author_name: ci-bot
branch: main
message: "[skip ci] automated docs update"
netrc_machine: gitea.rknet.org
netrc_password:
from_secret: gitea_token
when:
- event: [push, manual]
branch:
- ${CI_REPO_DEFAULT_BRANCH}
depends_on:
- test

View File

@ -1,30 +0,0 @@
---
when:
- event: [pull_request, tag]
- event: [push, manual]
branch:
- ${CI_REPO_DEFAULT_BRANCH}
steps:
- name: ansible-later
image: quay.io/thegeeklab/ansible-later:4
commands:
- ansible-later
environment:
FORCE_COLOR: "1"
- name: python-format
image: docker.io/python:3.12
commands:
- pip install -qq ruff
- ruff format --check --diff .
environment:
PY_COLORS: "1"
- name: python-lint
image: docker.io/python:3.12
commands:
- pip install -qq ruff
- ruff .
environment:
PY_COLORS: "1"

View File

@ -1,26 +0,0 @@
---
when:
- event: [tag]
- event: [push, manual]
branch:
- ${CI_REPO_DEFAULT_BRANCH}
runs_on: [success, failure]
steps:
- name: matrix
image: quay.io/thegeeklab/wp-matrix
settings:
homeserver:
from_secret: matrix_homeserver
password:
from_secret: matrix_password
roomid:
from_secret: matrix_roomid
username:
from_secret: matrix_username
when:
- status: [success, failure]
depends_on:
- docs

View File

@ -1,25 +0,0 @@
---
when:
- event: [pull_request, tag]
- event: [push, manual]
branch:
- ${CI_REPO_DEFAULT_BRANCH}
variables:
- &molecule_base
image: quay.io/thegeeklab/molecule:6
group: molecule
secrets:
- source: molecule_hcloud_token
target: HCLOUD_TOKEN
environment:
PY_COLORS: "1"
steps:
- name: molecule-default
<<: *molecule_base
commands:
- molecule test -s default
depends_on:
- lint

21
LICENSE
View File

@ -1,21 +0,0 @@
MIT License
Copyright (c) 2022 Robert Kaussow <mail@thegeeklab.de>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:
The above copyright notice and this permission notice (including the next
paragraph) shall be included in all copies or substantial portions of the
Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@ -1,24 +0,0 @@
---
wireguard_address: "10.0.0.1/24"
# @var:wireguard_port: The default port WireGuard will listen if not specified otherwise.
wireguard_port: "51820"
# The default interface name that WireGuard should use if not specified otherwise.
wireguard_interface: "wg0"
# @var:wireguard_private_key: Private key to use. If not private key is given, the role will auto-generate a new key.
# @var:wireguard_private_key:default: $ "_unset_"
# @var wireguard_dns:default: $ "_unset_"
# @var wireguard_fwmark:default: $ "_unset_"
# @var wireguard_mtu:default: $ "_unset_"
# @var wireguard_table:default: $ "_unset_"
wireguard_preup: []
wireguard_postup: []
wireguard_predown: []
wireguard_postdown: []
wireguard_peers: []
wireguard_peers_unmanaged: []

View File

@ -1,8 +0,0 @@
---
- name: Restart WireGuard
ansible.builtin.service:
name: "wg-quick@{{ wireguard_interface }}"
daemon_reload: True
enabled: True
state: restarted
listen: __wireguard_restart

View File

@ -1,13 +1,14 @@
# xoxys.wireguard
---
title: wireguard
type: docs
---
[![Build Status](https://ci.rknet.org/api/badges/ansible/xoxys.wireguard/status.svg)](https://ci.rknet.org/repos/ansible/xoxys.wireguard)
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg?label=license)](https://gitea.rknet.org/ansible/xoxys.wireguard/src/branch/main/LICENSE)
[![Source Code](https://img.shields.io/badge/gitea-source%20code-blue?logo=gitea&logoColor=white)](https://gitea.rknet.org/ansible/xoxys.wireguard) [![Build Status](https://img.shields.io/drone/build/ansible/xoxys.wireguard?logo=drone&server=https%3A%2F%2Fdrone.rknet.org)](https://drone.rknet.org/ansible/xoxys.wireguard) [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg?label=license)](https://gitea.rknet.org/ansible/xoxys.wireguard/src/branch/main/LICENSE)
Setup wireguard VPN.
## Table of content
<!--more-->
- [Requirements](#requirements)
- [Default Variables](#default-variables)
- [wireguard_address](#wireguard_address)
- [wireguard_interface](#wireguard_interface)
@ -19,15 +20,9 @@ Setup wireguard VPN.
- [wireguard_predown](#wireguard_predown)
- [wireguard_preup](#wireguard_preup)
- [Dependencies](#dependencies)
- [License](#license)
- [Author](#author)
---
## Requirements
- Minimum Ansible version: `2.10`
## Default Variables
### wireguard_address
@ -102,14 +97,8 @@ wireguard_predown: []
wireguard_preup: []
```
## Dependencies
None.
## License
MIT
## Author
[Robert Kaussow](https://gitea.rknet.org/xoxys)

View File

@ -1,21 +0,0 @@
---
galaxy_info:
# @meta author:value: [Robert Kaussow](https://gitea.rknet.org/xoxys)
author: "Robert Kaussow <mail@thegeeklab.de>"
namespace: xoxys
role_name: wireguard
# @meta description: >
# [![Build Status](https://ci.rknet.org/api/badges/ansible/xoxys.wireguard/status.svg)](https://ci.rknet.org/repos/ansible/xoxys.wireguard)
# [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg?label=license)](https://gitea.rknet.org/ansible/xoxys.wireguard/src/branch/main/LICENSE)
#
# Setup wireguard VPN.
# @end
description: Setup wireguard VPN
license: MIT
min_ansible_version: "2.10"
platforms:
- name: EL
versions:
- "9"
galaxy_tags: []
dependencies: []

View File

@ -1,5 +0,0 @@
---
- name: Converge
hosts: all
roles:
- role: xoxys.wireguard

View File

@ -1,17 +0,0 @@
---
driver:
name: molecule_hetznercloud
dependency:
name: galaxy
options:
role-file: molecule/requirements.yml
requirements-file: molecule/requirements.yml
platforms:
- name: "rocky9-wireguard"
server_type: "cx11"
image: "rocky-9"
provisioner:
name: ansible
log: False
verifier:
name: testinfra

View File

@ -1,11 +0,0 @@
---
- name: Prepare
hosts: all
gather_facts: False
tasks:
- name: Bootstrap Python for Ansible
ansible.builtin.raw: |
command -v python3 python ||
((test -e /usr/bin/apt && (apt -y update && apt install -y python-minimal)) ||
echo "Warning: Python not boostrapped due to unknown platform.")
changed_when: False

View File

@ -1,13 +0,0 @@
import os
import testinfra.utils.ansible_runner
testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
os.environ["MOLECULE_INVENTORY_FILE"]
).get_hosts("all")
def test_wireguard_running_and_enabled(host):
wireguard = host.service("wg-quick@wg0")
assert wireguard.is_running
assert wireguard.is_enabled

View File

@ -1,4 +0,0 @@
---
collections: []
roles: []

View File

@ -1,17 +0,0 @@
[tool.ruff]
exclude = [".git", "__pycache__"]
line-length = 99
indent-width = 4
[tool.ruff.lint]
ignore = ["W191", "E111", "E114", "E117", "S101", "S105"]
select = ["F", "E", "I", "W", "S"]
[tool.ruff.format]
quote-style = "double"
indent-style = "space"
line-ending = "lf"
[tool.pytest.ini_options]
filterwarnings = ["ignore::FutureWarning", "ignore::DeprecationWarning"]

View File

@ -1,70 +0,0 @@
---
- name: Ensure dependencies are installed
ansible.builtin.package:
name: "{{ item }}"
state: present
loop:
- wireguard-tools
- name: Stat WireGuard config file
ansible.builtin.stat:
path: "/etc/wireguard/{{ wireguard_interface }}.conf"
register: __wireguard_config_file
- when:
- not __wireguard_config_file.stat.exists
- wireguard_private_key is not defined
block:
- name: Generate WireGuard private key
ansible.builtin.command: "wg genkey"
register: __wireguard_private_key_gen
changed_when: False
- name: Set generated private key
ansible.builtin.set_fact:
wireguard_private_key: "{{ __wireguard_private_key_gen.stdout }}"
- when:
- __wireguard_config_file.stat.exists
- wireguard_private_key is not defined
block:
- name: Read WireGuard config file
ansible.builtin.slurp:
src: "/etc/wireguard/{{ wireguard_interface }}.conf"
register: __wireguard_config
- name: Set existing private key
ansible.builtin.set_fact:
wireguard_private_key: "{{ __wireguard_config['content'] | b64decode | regex_findall('PrivateKey = (.*)') | first }}"
- name: Derive WireGuard public key
ansible.builtin.command: "wg pubkey"
args:
stdin: "{{ wireguard_private_key }}"
register: __wireguard_public_key_gen
changed_when: False
- name: Set public key fact
ansible.builtin.set_fact:
__wireguard_public_key: "{{ __wireguard_public_key_gen.stdout }}"
- name: Generate WireGuard configuration file
ansible.builtin.template:
src: etc/wireguard/wg.conf.j2
dest: "/etc/wireguard/{{ wireguard_interface }}.conf"
owner: root
group: root
mode: "0600"
notify: __wireguard_restart
- name: Ensure legacy reload-module-on-update is absent
ansible.builtin.file:
dest: "/etc/wireguard/.reload-module-on-update"
state: absent
- name: Ensure WireGuard service is up and running
ansible.builtin.service:
name: "wg-quick@{{ wireguard_interface }}"
daemon_reload: True
enabled: True
state: started

View File

@ -1,72 +0,0 @@
#jinja2: lstrip_blocks: True
# {{ ansible_managed }}
[Interface]
## {{ inventory_hostname }}
Address = {{ wireguard_address }}
PrivateKey = {{ wireguard_private_key }}
ListenPort = {{ wireguard_port }}
{% if wireguard_dns is defined %}
DNS = {{ wireguard_dns }}
{% endif %}
{% if wireguard_fwmark is defined %}
FwMark = {{ wireguard_fwmark }}
{% endif %}
{% if wireguard_mtu is defined %}
MTU = {{ wireguard_mtu }}
{% endif %}
{% if wireguard_table is defined %}
Table = {{ wireguard_table }}
{% endif %}
{% for wg_preup in wireguard_preup %}
PreUp = {{ wg_preup }}
{% endfor %}
{% for wg_postup in wireguard_postup %}
PostUp = {{ wg_postup }}
{% endfor %}
{% for wg_predown in wireguard_predown %}
PreDown = {{ wg_predown }}
{% endfor %}
{% for wg_postdown in wireguard_postdown %}
PostDown = {{ wg_postdown }}
{% endfor %}
SaveConfig = false
{% for host in wireguard_peers %}
{% if host != inventory_hostname %}
[Peer]
## {{ host }}
PublicKey = {{ hostvars[host].__wireguard_public_key }}
{% if hostvars[host].wireguard_allowed_ips | length > 0 %}
AllowedIPs = {{ hostvars[host].wireguard_allowed_ips | join(",") }}
{% else %}
AllowedIPs = {{ hostvars[host].wireguard_address.split('/')[0] }}/32
{% endif %}
{% if hostvars[host].wireguard_persistent_keepalive is defined %}
PersistentKeepalive = {{ hostvars[host].wireguard_persistent_keepalive }}
{% endif %}
{% if hostvars[host].wireguard_endpoint is not defined or not hostvars[host].wireguard_endpoint %}
Endpoint = {{ hostvars[host].wireguard_endpoint | default(host) }}:{{ hostvars[host].wireguard_port | default(wireguard_port) }}
{% endif %}
{% endif %}
{% endfor %}
{% if wireguard_peers_unmanaged | length > 0 %}
# Peers not managed by Ansible
{% for peer in wireguard_peers_unmanaged %}
[Peer]
# {{ peer.name }}
PublicKey = {{ peer.public_key }}
{% if peer.preshared_key is defined %}
PresharedKey = {{ peer.preshared_key }}
{% endif %}
{% if peer.allowed_ips | length > 0 %}
AllowedIPs = {{ peer.allowed_ips | join(",") }}
{% endif %}
{% if peer.endpoint is defined %}
Endpoint = {{ peer.endpoint }}
{% endif %}
{% if peer.persistent_keepalive is defined %}
PersistentKeepalive = {{ peer.persistent_keepalive }}
{% endif %}
{% endfor %}
{% endif %}