summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--module/ri-wireguard/src/main/resources/io/trygvis/rules/wireguard/wireguard.drl1
-rw-r--r--module/ri-wireguard/src/main/resources/templates/wireguard/ansible-host.j23
-rw-r--r--module/ri-wireguard/src/main/resources/templates/wireguard/ansible.j24
-rw-r--r--module/ri-wireguard/src/main/resources/templates/wireguard/inventory.j26
4 files changed, 10 insertions, 4 deletions
diff --git a/module/ri-wireguard/src/main/resources/io/trygvis/rules/wireguard/wireguard.drl b/module/ri-wireguard/src/main/resources/io/trygvis/rules/wireguard/wireguard.drl
index 97d17cb..425b6ca 100644
--- a/module/ri-wireguard/src/main/resources/io/trygvis/rules/wireguard/wireguard.drl
+++ b/module/ri-wireguard/src/main/resources/io/trygvis/rules/wireguard/wireguard.drl
@@ -156,6 +156,7 @@ then
}
te.template("wireguard/inventory", "inventory.yml", Map.of(
+ "net", $net,
"hosts", machines
));
end
diff --git a/module/ri-wireguard/src/main/resources/templates/wireguard/ansible-host.j2 b/module/ri-wireguard/src/main/resources/templates/wireguard/ansible-host.j2
index a3c8c40..cbf707e 100644
--- a/module/ri-wireguard/src/main/resources/templates/wireguard/ansible-host.j2
+++ b/module/ri-wireguard/src/main/resources/templates/wireguard/ansible-host.j2
@@ -2,7 +2,6 @@
link_address: {{ host.ip }}
network_cidr: {{ host.networkCidr }}
wireguard_peers:
- {{ host.machine.name }}:
{%- for peer in peers %}
- - {{ peer.fqdn }}
+ - {{ peer.fqdn }}
{%- endfor %}
diff --git a/module/ri-wireguard/src/main/resources/templates/wireguard/ansible.j2 b/module/ri-wireguard/src/main/resources/templates/wireguard/ansible.j2
index 82c0ca0..bca3e8c 100644
--- a/module/ri-wireguard/src/main/resources/templates/wireguard/ansible.j2
+++ b/module/ri-wireguard/src/main/resources/templates/wireguard/ansible.j2
@@ -1,6 +1,6 @@
-- hosts: {{ net.name }}
+- hosts: wireguard_{{ net.name }}
roles:
- name: wireguard
wireguard_if: {{ net.name }}
wireguard_listen_port: 45364
- wireguard_address4: "{{ '{{' }} link_addresses[ansible_hostname] }}"
+ wireguard_address4: "{{ '{{' }} link_address }}"
diff --git a/module/ri-wireguard/src/main/resources/templates/wireguard/inventory.j2 b/module/ri-wireguard/src/main/resources/templates/wireguard/inventory.j2
index 0924bb2..64f3b5b 100644
--- a/module/ri-wireguard/src/main/resources/templates/wireguard/inventory.j2
+++ b/module/ri-wireguard/src/main/resources/templates/wireguard/inventory.j2
@@ -5,3 +5,9 @@ all:
{{ host.getName() }}:
ansible_host: {{ host.getFqdn() }}
{%- endfor %}
+ children:
+ wireguard_{{ net.name }}:
+ hosts:
+{%- for host in hosts %}
+ {{ host.getName() }}:
+{%- endfor %}