From 8192f76787f975904a4f2df6d194966efdd53702 Mon Sep 17 00:00:00 2001 From: Kris Lamoureux Date: Thu, 15 Apr 2021 22:52:43 -0400 Subject: [PATCH] Iterate over a variable for network management --- roles/base/tasks/network.yml | 3 ++- roles/base/templates/static-interface.cfg | 8 ++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/roles/base/tasks/network.yml b/roles/base/tasks/network.yml index 7cfe65e..c154ecc 100644 --- a/roles/base/tasks/network.yml +++ b/roles/base/tasks/network.yml @@ -9,8 +9,9 @@ - name: Install network interfaces template: src: "{{ network_type }}-interface.cfg" - dest: "/etc/network/interfaces.d/{{ ip_inter }}" + dest: "/etc/network/interfaces.d/{{ item.name }}" notify: reboot_host + loop: "{{ interfaces }}" - name: Install bridge utilities apt: diff --git a/roles/base/templates/static-interface.cfg b/roles/base/templates/static-interface.cfg index f7d04b2..b58ba45 100644 --- a/roles/base/templates/static-interface.cfg +++ b/roles/base/templates/static-interface.cfg @@ -1,7 +1,7 @@ # {{ ansible_managed }} # The primary network interface -auto {{ ip_inter }} -iface {{ ip_inter }} inet static - address {{ ip_addr }} - gateway {{ ip_gateway }} +auto {{ item.name }} +iface {{ item.name }} inet static + address {{ item.address }} + gateway {{ item.gateway }}