From 44ec2ae19712338c3c5bb232961dc72e569dce72 Mon Sep 17 00:00:00 2001 From: Kris Lamoureux Date: Fri, 16 Apr 2021 01:40:50 -0400 Subject: [PATCH] Simplify to a single network interface template --- roles/base/tasks/network.yml | 5 ++--- roles/base/templates/bridged-interface.cfg | 10 ---------- roles/base/templates/interface.j2 | 16 ++++++++++++++++ roles/base/templates/static-interface.cfg | 7 ------- 4 files changed, 18 insertions(+), 20 deletions(-) delete mode 100644 roles/base/templates/bridged-interface.cfg create mode 100644 roles/base/templates/interface.j2 delete mode 100644 roles/base/templates/static-interface.cfg diff --git a/roles/base/tasks/network.yml b/roles/base/tasks/network.yml index c154ecc..404db19 100644 --- a/roles/base/tasks/network.yml +++ b/roles/base/tasks/network.yml @@ -8,13 +8,12 @@ - name: Install network interfaces template: - src: "{{ network_type }}-interface.cfg" + src: "interface.j2" dest: "/etc/network/interfaces.d/{{ item.name }}" - notify: reboot_host loop: "{{ interfaces }}" + notify: reboot_host - name: Install bridge utilities apt: name: bridge-utils state: present - when: network_type == "bridged" diff --git a/roles/base/templates/bridged-interface.cfg b/roles/base/templates/bridged-interface.cfg deleted file mode 100644 index 7e2ee28..0000000 --- a/roles/base/templates/bridged-interface.cfg +++ /dev/null @@ -1,10 +0,0 @@ -# {{ ansible_managed }} - -# The primary network interface -auto br1 -iface br1 inet static - address {{ ip_addr }} - gateway {{ ip_gateway }} - bridge_ports {{ ip_inter }} - bridge_stp on - ethernet-wol g diff --git a/roles/base/templates/interface.j2 b/roles/base/templates/interface.j2 new file mode 100644 index 0000000..207451b --- /dev/null +++ b/roles/base/templates/interface.j2 @@ -0,0 +1,16 @@ +# {{ ansible_managed }} + +{% if item.bridge is defined %} +auto br1 +iface br1 inet static +{% else %} +auto {{ item.name }} +iface {{ item.name }} inet static +{% endif %} + address {{ item.address }} +{% if item.gateway is defined %} + gateway {{ item.gateway }} +{% endif %} +{% if item.bridge is defined %} + bridge_ports {{ item.name }} +{% endif %} diff --git a/roles/base/templates/static-interface.cfg b/roles/base/templates/static-interface.cfg deleted file mode 100644 index b58ba45..0000000 --- a/roles/base/templates/static-interface.cfg +++ /dev/null @@ -1,7 +0,0 @@ -# {{ ansible_managed }} - -# The primary network interface -auto {{ item.name }} -iface {{ item.name }} inet static - address {{ item.address }} - gateway {{ item.gateway }}