From 0ae7ecd47fd76921e8e1137739497578fe703354 Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Tue, 26 Jan 2021 21:06:24 +0100 Subject: Better main(). * Moving templates into their respective modules. * Supporting export type-based filtering. Probably not perfect. --- .../src/main/resources/templates/wireguard/ansible-host.j2 | 8 ++++++++ .../src/main/resources/templates/wireguard/ansible.j2 | 6 ++++++ .../src/main/resources/templates/wireguard/inventory.j2 | 7 +++++++ 3 files changed, 21 insertions(+) create mode 100644 module/ri-wireguard/src/main/resources/templates/wireguard/ansible-host.j2 create mode 100644 module/ri-wireguard/src/main/resources/templates/wireguard/ansible.j2 create mode 100644 module/ri-wireguard/src/main/resources/templates/wireguard/inventory.j2 (limited to 'module/ri-wireguard') 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 new file mode 100644 index 0000000..a3c8c40 --- /dev/null +++ b/module/ri-wireguard/src/main/resources/templates/wireguard/ansible-host.j2 @@ -0,0 +1,8 @@ +# Generated +link_address: {{ host.ip }} +network_cidr: {{ host.networkCidr }} +wireguard_peers: + {{ host.machine.name }}: +{%- for peer in peers %} + - {{ 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 new file mode 100644 index 0000000..82c0ca0 --- /dev/null +++ b/module/ri-wireguard/src/main/resources/templates/wireguard/ansible.j2 @@ -0,0 +1,6 @@ +- hosts: {{ net.name }} + roles: + - name: wireguard + wireguard_if: {{ net.name }} + wireguard_listen_port: 45364 + wireguard_address4: "{{ '{{' }} link_addresses[ansible_hostname] }}" diff --git a/module/ri-wireguard/src/main/resources/templates/wireguard/inventory.j2 b/module/ri-wireguard/src/main/resources/templates/wireguard/inventory.j2 new file mode 100644 index 0000000..0924bb2 --- /dev/null +++ b/module/ri-wireguard/src/main/resources/templates/wireguard/inventory.j2 @@ -0,0 +1,7 @@ +# Generated +all: + hosts: + {%- for host in hosts %} + {{ host.getName() }}: + ansible_host: {{ host.getFqdn() }} + {%- endfor %} -- cgit v1.2.3