3
Using WireGuard Easy with Ansible
Philip H. edited this page 2024-09-03 00:03:02 +02:00

Description

This playbook is designed to automate the installation of Docker and Wireguard Easy on your virtual machine using Ansible.


Installing Ansible

To begin, install Ansible by following the official documentation.


Downloading the Playbook

Clone the repository containing the Wireguard playbook:

Copy code

git clone https://gitlab.com/CTPEJIKuH/wireguard-playbook
cd wireguard-playbook

Configuring Variables and VM IP Address

In the inventories/prod/inventory.yml file, specify the IP address of your virtual machine:

all:
  children:
    prod:

wireguard_addresses:
  hosts:
    your-vm:
      ansible_host: 123.45.67.89

Instead of your-vm, specify the name of your virtual machine.

Instead of 123.45.67.89, you need to specify the IP of your virtual machine.

In the inventories/prod/group_vars/all.yml file, set the password for the Wireguard web interface:

wg_easy_password_hash

you need create a password hash https://github.com/wg-easy/wg-easy/blob/master/How_to_generate_an_bcrypt_hash.md`

Other variables are also available in the role that can be configured. Details can be found here. The playbook also provides backup functionality.


Entry Point

At the end of the Ansible run, a message like the following will be displayed your UI address:

TASK [wireguard : Output UI address] *******************************************************************************
ok: [your-vm] => {
    "msg": "UI address: http://123.45.67.89:51821"
}

Example Playbook

Deployment with a check:

ansible-playbook -i inventories/prod main.yml -D -C

Deployment without check:

ansible-playbook -i inventories/prod main.yml -D