Skip to content

feat: add support for wireguard vpn#80

Open
iambaboucarr wants to merge 14 commits into
mainfrom
feat/wireguard-vpn
Open

feat: add support for wireguard vpn#80
iambaboucarr wants to merge 14 commits into
mainfrom
feat/wireguard-vpn

Conversation

@iambaboucarr

@iambaboucarr iambaboucarr commented Mar 31, 2026

Copy link
Copy Markdown
Collaborator

This PR adds support for Wireguard VPN

WireGuard local client
Screenshot 2026-04-06 at 13 49 29

Glowroot local access (via WireGuard)
Screenshot 2026-04-06 at 13 50 24

Grafana local access (via WireGuard)
Screenshot 2026-04-06 at 17 36 23

DB access via local PgAdmin client (via WireGuard)
Screenshot 2026-04-06 at 17 35 36

- Added validation tasks to ensure each VPN peer has required fields (name, public_key, allowed_ips) and that allowed_ips are unique.
- Updated comments and documentation for clarity regarding VPN access restrictions.
- Adjusted firewall rules and monitoring configurations to support the new setup.
@iambaboucarr iambaboucarr marked this pull request as ready for review April 6, 2026 17:31

@jason-p-pickering jason-p-pickering left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

- Modified .gitignore to allow specific files in group_vars and host_vars directories.
- Updated hosts.template to reflect changes in configuration file paths.
- Added vars.yml for WireGuard VPN peers configuration, including key generation instructions.
Comment thread deploy/roles/wireguard/tasks/lockdown_proxy.yml Fixed
- Modified the pg_hba.conf entry for VPN users to use 'hostssl' instead of 'host', enforcing SSL connections for added security.
- Updated documentation to reflect the change in access requirements, emphasizing the need for SSL even with VPN encryption.
- Added conditional logic to Apache2 and Nginx instance templates to enable Glowroot monitoring only when not locked down by WireGuard settings.
- Updated tasks to re-render instance configurations for both Apache2 and Nginx without Glowroot proxy blocks based on the defined conditions.
…erver-side

- Introduced `wireguard_auto_generate_keys` and `wireguard_auto_generate_psk` options to allow server-side key generation for clients, simplifying peer configuration.
- Updated validation tasks to ensure peers have required fields based on the key generation mode.
- Enhanced documentation to clarify the new configuration options and their implications for client setup.
- Added tasks for generating client keys and managing orphaned key files, improving overall management of WireGuard peers.
- Introduced a dedicated LXD container for the WireGuard hub, improving isolation and management of VPN services.
- Updated playbook to include tasks for provisioning the hub container, managing UDP port forwarding, and generating peer configurations.
- Enhanced peer setup tasks to pull configurations from the hub, ensuring secure and consistent VPN access for app containers.
- Refactored existing tasks to streamline the WireGuard role, removing deprecated server setup tasks and improving overall clarity and maintainability.
@sonarqubecloud

sonarqubecloud Bot commented May 5, 2026

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
1 New issue
1 New Vulnerabilities (required ≤ 0)
C Security Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

@tkipkurgat

tkipkurgat commented May 18, 2026

Copy link
Copy Markdown
Contributor

The PR does not work, -- there is an error running playboook,

image

Its not distributed setup ready, -- there are tasks taht are lxd related, should be called only if ansible connection is lxd.

image

Keep it simple

Have wireguard playbook running separately, -- this playbook imports wireguard related tasks. Which at this stage should just

  • craate lxd container if setup is lxd
  • setup wirteguard server,
  • setup and confire wiregurd network across all hosts, via wireguard server (lxd or standalone )
  • then after that, we can go to step 2, decide what needs to be exposed to wireguard, i.e lockdown_playbooks.

There are tasks that harden firewall, removing rules which were not even there before, -- I think there are not needed, since you branch has never been merged,

lockdown_monitor.yml removes:

  • UFW rule src={{ lxd_gateway_ip }} for Grafana, Prometheus, Munin
  • UFW rule src={{ hostvars[item]['ansible_host'] }} (proxy container IP) → Grafana

lockdown_postgres.yml removes:

  • pg_hba.conf line hostssl all all {{ lxd_gateway_ip }}/32

lockdown_instances.yml removes:

  • UFW rule src={{ lxd_gateway_ip }} for Glowroot (4000)

…atures

- Introduced `playbooks/wireguard.yml` for standalone WireGuard mesh setup, allowing for easier debugging and management.
- Added `playbooks/wireguard-lockdown.yml` to restrict access to Grafana, Prometheus, Munin, Glowroot, and PostgreSQL to the VPN subnet.
- Updated `dhis2.yml` to auto-import the new playbooks, streamlining the deployment process.
- Refactored instance configuration templates to conditionally remove Glowroot proxy blocks based on lockdown settings.
- Adjusted role defaults and tasks to improve clarity and maintainability, including disabling legacy monitoring lockdown behavior.
@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
1 New issue
1 New Vulnerabilities (required ≤ 0)
C Security Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

- Enhanced `wireguard.yml` to accurately capture the deployment mode from the wireguard hub host's hostvars, ensuring correct behavior in LXD environments.
- Added a new task in `hub.yml` to wait for LXD connection readiness, improving reliability during the deployment process.
- Introduced a wait task in `lxd_container.yml` for cloud-init completion, preventing race conditions that could lead to installation failures.
Comment thread deploy/roles/wireguard/tasks/lockdown_proxy.yml Fixed
@sonarqubecloud

sonarqubecloud Bot commented Jun 9, 2026

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants