-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #35 from coderat-collective/add-tunnel-config
Add tunnel config
- Loading branch information
Showing
9 changed files
with
156 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
--- | ||
- name: Converge | ||
hosts: all | ||
become: true | ||
vars: | ||
netplan_renderer: 'NetworkManager' | ||
debug: true | ||
netplan_configuration: | ||
network: | ||
version: 2 | ||
tunnels: | ||
wg_test: | ||
mode: wireguard | ||
addresses: | ||
- 10.42.42.2/32 | ||
nameservers: | ||
addresses: | ||
- 10.10.10.1 | ||
search: | ||
- dns.example.com | ||
key: 'gDdP5JHM6VQQOeGZPLANiTMa+V2bbwyR8Z2o86m7gUg=' | ||
peers: | ||
- keys: | ||
public: 'KqOQG90uvqVWGHwLW+Z5tH019Qt5QcIhpKitIovkviA=' | ||
allowed-ips: | ||
- 10.10.10.0/24 | ||
keepalive: 15 | ||
endpoint: 'wireguard.example.com:51820' | ||
routes: | ||
- to: 10.10.10.0/24 | ||
tasks: | ||
- name: "Include ansible-netplan" | ||
include_role: | ||
name: "mrlesmithjr.netplan" |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
--- | ||
dependency: | ||
name: galaxy | ||
options: | ||
ignore-certs: true | ||
ignore-errors: true | ||
driver: | ||
name: vagrant | ||
platforms: | ||
- name: vagrant-ubuntu | ||
box: ubuntu/focal64 | ||
memory: 4048 | ||
cpus: 4 | ||
instance_raw_config_args: | ||
- "vm.network 'forwarded_port', guest: 8081, host: 30080" | ||
provisioner: | ||
name: ansible | ||
lint: ansible-lint --force-color | ||
lint: | | ||
set -e | ||
yamllint . | ||
ansible-lint | ||
verifier: | ||
name: ansible |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
--- | ||
- name: Prepare | ||
hosts: all | ||
become: true | ||
tasks: | ||
- name: Update apt cache | ||
ansible.builtin.apt: | ||
update_cache: true | ||
cache_valid_time: 3600 | ||
when: ansible_os_family == 'Debian' |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
--- | ||
# This is an example playbook to execute Ansible tests. | ||
|
||
- name: Verify | ||
hosts: all | ||
gather_facts: false | ||
vars: | ||
# netplan_renderer: 'NetworkManager' | ||
netplan_configuration: | ||
network: | ||
version: '2' | ||
tunnels: | ||
wg_test: | ||
mode: wireguard | ||
addresses: | ||
- 10.42.42.2/32 | ||
nameservers: | ||
addresses: | ||
- 10.10.10.1 | ||
search: | ||
- dns.example.com | ||
key: 'gDdP5JHM6VQQOeGZPLANiTMa+V2bbwyR8Z2o86m7gUg=' | ||
peers: | ||
- keys: | ||
public: 'KqOQG90uvqVWGHwLW+Z5tH019Qt5QcIhpKitIovkviA=' | ||
allowed-ips: | ||
- 10.10.10.0/24 | ||
keepalive: '15' | ||
endpoint: 'wireguard.example.com:51820' | ||
routes: | ||
- to: 10.10.10.0/24 | ||
become: true | ||
become_user: root | ||
tasks: | ||
- name: Read netplan config | ||
ansible.builtin.slurp: | ||
src: '/etc/netplan/ansible-config.yaml' | ||
register: netplan_wg_config_encoded | ||
|
||
- name: Check wireguard config | ||
ansible.builtin.assert: | ||
that: | ||
- netplan_configuration.network.version in netplan_wg_config | ||
- netplan_configuration.network.tunnels.wg_test.mode in netplan_wg_config | ||
- netplan_configuration.network.tunnels.wg_test.addresses[0] in netplan_wg_config | ||
- netplan_configuration.network.tunnels.wg_test.nameservers.addresses[0] in netplan_wg_config | ||
- netplan_configuration.network.tunnels.wg_test.nameservers.search[0] in netplan_wg_config | ||
- netplan_configuration.network.tunnels.wg_test.key in netplan_wg_config | ||
- netplan_configuration.network.tunnels.wg_test.peers[0]['keys']['public'] in netplan_wg_config | ||
- netplan_configuration.network.tunnels.wg_test.peers[0]['allowed-ips'][0] in netplan_wg_config | ||
- netplan_configuration.network.tunnels.wg_test.peers[0].keepalive in netplan_wg_config | ||
- netplan_configuration.network.tunnels.wg_test.peers[0].endpoint in netplan_wg_config | ||
- netplan_configuration.network.tunnels.wg_test.routes[0].to in netplan_wg_config | ||
vars: | ||
- netplan_wg_config: "{{ netplan_wg_config_encoded.content | b64decode }}" |
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
--- | ||
netplan_networkmanager_pkt: 'network-manager' | ||
# vars file for ansible-netplan |