Feature: miltiple wireguard profiles#45
Open
vix-4800 wants to merge 4 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR extends the network Ansible role’s WireGuard support from a single fixed wg0 configuration to a list of named WireGuard profiles, enabling deployment/import of multiple WireGuard configs and NetworkManager connections from vault data.
Changes:
- Replaced single WireGuard vault variables with
vault_wg_profiles(list of profile objects), while keeping a legacy fallback path. - Updated the WireGuard Jinja2 template to render from a selected
network_wireguard_profile(supporting string-or-list forms for address/DNS/AllowedIPs). - Refactored WireGuard tasks to loop over profiles and configure each one via a dedicated
wireguard-profile.ymlinclude.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
vault/secrets.yml.example |
Updates the secrets example to a multi-profile vault_wg_profiles structure. |
roles/network/templates/wg0.conf.j2 |
Renders a WireGuard config from a per-profile object (address/DNS/AllowedIPs normalization). |
roles/network/tasks/wireguard.yml |
Normalizes profiles, validates uniqueness, and loops per profile to configure/import. |
roles/network/tasks/wireguard-profile.yml |
New per-profile tasks to template the config and import it into NetworkManager. |
README.md |
Updates documentation to describe profile-based WireGuard secrets and deployed config paths. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+6
to
+29
| vault_wg_profiles: | ||
| - name: wg0 | ||
| private_key: "CHANGEME" | ||
| address: | ||
| - "10.0.0.2/32" | ||
| - "fd00::2/128" | ||
| dns: | ||
| - "1.1.1.1" | ||
| - "2606:4700:4700::1111" | ||
| peer_public_key: "CHANGEME" | ||
| preshared_key: "CHANGEME" | ||
| persistent_keepalive: 25 | ||
| endpoint: "vpn-1.example.com:51820" | ||
| allowed_ips: | ||
| - "0.0.0.0/0" | ||
| - "::/0" | ||
| - name: wg1 | ||
| private_key: "CHANGEME" | ||
| address: "10.10.0.2/32" | ||
| dns: "9.9.9.9" | ||
| peer_public_key: "CHANGEME" | ||
| preshared_key: "" | ||
| persistent_keepalive: 0 | ||
| endpoint: "vpn-2.example.com:51820" |
Comment on lines
+23
to
+29
| 'private_key': vault_wg_private_key, | ||
| 'address': vault_wg_address, | ||
| 'dns': vault_wg_dns, | ||
| 'peer_public_key': vault_wg_peer_public_key, | ||
| 'preshared_key': vault_wg_preshared_key | default(''), | ||
| 'persistent_keepalive': vault_wg_persistent_keepalive, | ||
| 'endpoint': vault_wg_endpoint |
Comment on lines
+53
to
+59
| - name: Assert WireGuard profile names are unique | ||
| ansible.builtin.assert: | ||
| that: | ||
| - network_wireguard_named_profile_count == network_wireguard_profile_count | ||
| - network_wireguard_unique_profile_count == network_wireguard_profile_count | ||
| fail_msg: Each WireGuard profile must define a unique name. | ||
| changed_when: false |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.