sergelogvinov / ansible-role-wireguard

Wireguard mesh network

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Ansible role wireguard

Easy way to configure wireguard peers

Install

ansible-galaxy role install git+https://github.com/sergelogvinov/ansible-role-wireguard.git,main

Usage

Create wireguard keys

export ANSIBLE_VAULT_PASSWORD_FILE=pwd_file

make wireguard-key

Deploy mesh network

# inventory file

[peering]
peer1          ansible_host=1.2.3.1
peer2          ansible_host=1.2.3.2
peer3          ansible_host=1.2.3.3
# hosts/peerX.yaml

# from `make wireguard-key`
wireguard_private_key: --key--
wireguard_public_key: --key--
# peers.yml

- hosts: peering
  vars:
    wireguard_peers: "{{ groups['all'] | difference(inventory_hostname) | map('extract', hostvars) |
      community.general.json_query('[?wireguard_public_key].{ ep: ansible_host, pub: wireguard_public_key, ips: wireguard_interface_address }') }}"
  roles:
    - ansible-role-wireguard

Finaly, apply the config:

ansible-playbook -Dv -i peers.ini peers.yml

About

Wireguard mesh network

License:MIT License


Languages

Language:Jinja 78.3%Language:Makefile 21.7%