From 4a40030a65f8029740d5c9ccb226114073f52eb8 Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Sun, 18 Aug 2024 09:43:30 +0200 Subject: Better if support --- tnet/wg-links-link.yml | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'tnet/wg-links-link.yml') diff --git a/tnet/wg-links-link.yml b/tnet/wg-links-link.yml index 632024e..c1c520b 100644 --- a/tnet/wg-links-link.yml +++ b/tnet/wg-links-link.yml @@ -1,3 +1,12 @@ +- set_fact: + if_name: tnet-{{ item.value.if_name|default(item.key) }} + +#- debug: +# msg: | +# if_name {{ if_name }} +# item.value.if_name {{ item.value.if_name|default("NOT SET") }} +# item.key {{ item.key }} + - notify: systemctl restart systemd-networkd become: yes file: @@ -7,10 +16,8 @@ - name: "Make netdev for {{ inventory_hostname }} -> {{ item.key }}" notify: systemctl restart systemd-networkd become: yes - vars: - if_name: tnet-{{ item.if_name|default(item.key) }} copy: - dest: "/etc/systemd/network/50-tnet-{{ item.key }}.netdev" + dest: "/etc/systemd/network/50-{{ if_name }}.netdev" owner: systemd-network group: adm mode: 0640 @@ -44,12 +51,12 @@ notify: systemctl restart systemd-networkd become: yes copy: - dest: "/etc/systemd/network/50-tnet-{{ item.key }}.network" + dest: "/etc/systemd/network/50-{{ if_name }}.network" owner: systemd-network group: adm content: | [Match] - Name=tnet-{{ item.key }} + Name={{ if_name }} [Network] Address={{ item.value.address }}/64 -- cgit v1.2.3