https://github.com/verschlimmbesserer/wireguard
https://github.com/verschlimmbesserer/wireguard
ansible ansible-role role
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/verschlimmbesserer/wireguard
- Owner: verschlimmbesserer
- License: gpl-3.0
- Created: 2023-05-05T21:31:06.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2024-08-05T03:28:07.000Z (almost 2 years ago)
- Last Synced: 2025-01-09T10:17:46.263Z (over 1 year ago)
- Topics: ansible, ansible-role, role
- Language: Jinja
- Homepage:
- Size: 19.5 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Wireguard
=========
This role installs `wireguard` and generates the nessesary keys as the configurations as well.
It uses the `ansible.builtin.slurp` collection to pickup the generated private and public keys. If the files exists or after the got generated. It is also possible to use a pre generated Private Key in the interface dictionary under the wireguard variable.
Requirements
------------
Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required.
Role Variables
--------------
|name|type|function|
|---|---|---|
|`wireguard_public_key_prefix:`| str | prefix for the wireguard public key|
| `wireguard_key_filename:`| str | name used for the key filenames, when not set will default to `{{ ansible_hostname }}`|
|`wireguard_create_keys:`| bool | By default Ansible will attempt to creaet the wireguard private and public key. |
|`wireguard`| dict | contains the configuration for the `wg0.conf` with the keys `interface` and `peers` which contains each `peer` as dictionary.|
Example Variables Configuration
------------
Site 2 Site VPN, when both Host are managed by Ansible in the same group.
Host in the US:
```Yaml
wireguard_private_key_name: "{{ ansible_hostname }}"
wireguard_create_keys: true
wireguard:
interface:
ListenPort: 51820
Address: 10.10.9.2/32
PostUp: iptables -A FORWARD -i wg0 -j ACCEPT
PostDown: iptables -D FORWARD -i wg0 -j ACCEPT
peers:
wg01-euro:
PersistentKeepalive: 25
Endpoint: "{{ hostvars['wg01-euro']['ansible_default_ipv4.address'] }}:51820"
PublicKey: "{{ hostvars['wg01-euro']['wg_public_key']}}"
AllowedIPs: 10.10.0.0/24,10.10.9.0/30
```
Host in Europe:
```Yaml
wireguard_private_key_name: "{{ ansible_hostname }}"
wireguard_create_keys: true
wireguard:
interface:
ListenPort: 51820
Address: 10.10.9.1/32
PostUp: iptables -A FORWARD -i wg0 -j ACCEPT
PostDown: iptables -D FORWARD -i wg0 -j ACCEPT
peers:
wg01-usa:
PersistentKeepalive: 25
Endpoint: "{{ hostvars['wg01-usa']['ansible_default_ipv4.address'] }}:51820"
PublicKey: "{{ hostvars['wg01-usa']['wg_public_key']}}"
AllowedIPs: 10.10.0.0/24,10.10.9.0/30
```
Dependencies
------------
A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles.
Example Playbook
----------------
Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too:
- hosts: servers
roles:
- { role: username.rolename, x: 42 }
License
-------
GNU General Public License v3.0
Author Information
------------------
An optional section for the role authors to include contact information, or a website (HTML is not allowed).