From 1ac05ad5cc0bdd3899bba85b86fb614b2d6ffddd Mon Sep 17 00:00:00 2001 From: Timo Makinen Date: Tue, 17 Jun 2025 20:36:12 +0000 Subject: [PATCH] Use more dynamic group config for dna-gw hosts --- group_vars/dnagw.yml | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/group_vars/dnagw.yml b/group_vars/dnagw.yml index b53027a..e533ff6 100644 --- a/group_vars/dnagw.yml +++ b/group_vars/dnagw.yml @@ -2,29 +2,38 @@ # increase memory size mem_size: 512 +intnet_netmask: "{{ network_interfaces[0].netmask }}" +intnet_prefix: >- + {% set ip = network_interfaces[0].ipaddr.split('.') -%} + {% if intnet_netmask == '255.255.252.0' -%} + {{ [ ip[0], ip[1], ip[2] | int - 1 ] | join('.') -}} + {% else -%} + {{ [ ip[0], ip[1], ip[2] ] | join('.') -}} + {% endif -%} + network_vip_interfaces: - device: vio0 vhid: 1 - ipaddr: 172.20.20.1 - netmask: 255.255.252.0 + ipaddr: "{{ intnet_prefix }}.1" + netmask: "{{ intnet_netmask }}" pass: "{{ vip1_pass }}" priority: 120 - device: vio0 vhid: 10 - ipaddr: 172.20.20.10 - netmask: 255.255.252.0 + ipaddr: "{{ intnet_prefix }}.10" + netmask: "{{ intnet_netmask }}" pass: "{{ vip10_pass }}" priority: 120 - device: vio0 vhid: 11 - ipaddr: 172.20.20.11 - netmask: 255.255.252.0 + ipaddr: "{{ intnet_prefix }}.11" + netmask: "{{ intnet_netmask }}" pass: "{{ vip11_pass }}" priority: "{{ vip11_priority }}" - device: vio0 vhid: 12 - ipaddr: 172.20.20.12 - netmask: 255.255.252.0 + ipaddr: "{{ intnet_prefix }}.12" + netmask: "{{ intnet_netmask }}" pass: "{{ vip12_pass }}" priority: "{{ vip12_priority }}" network_ether_interfaces: @@ -43,4 +52,4 @@ ifstated_config: ifstated-dna.conf.j2 # ssh host alaises ssh_hostnames: - - gw.home.foo.sh + - "gw.{{ inventory_hostname.split('.')[1] }}.foo.sh"