From d399fc0a24c72a0718338fc4dbc97086cbb9da2e Mon Sep 17 00:00:00 2001 From: Timotej Lazar Date: Mon, 20 Nov 2023 14:13:46 +0100 Subject: [PATCH] proxmox: simplify interface setup tasks --- roles/proxmox/tasks/main.yml | 24 ++++++++++-------------- templates/fabric.intf.j2 | 4 ++-- 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/roles/proxmox/tasks/main.yml b/roles/proxmox/tasks/main.yml index 243caa9..16b277e 100644 --- a/roles/proxmox/tasks/main.yml +++ b/roles/proxmox/tasks/main.yml @@ -24,20 +24,6 @@ mode: 0644 notify: reboot -- name: Set up loopback interface - template: - dest: /etc/network/interfaces.d/loopback.intf - src: loopback.intf.j2 - mode: 0644 - notify: reload interfaces - -- name: Set up fabric interfaces - template: - dest: /etc/network/interfaces.d/fabric.intf - src: fabric.intf.j2 - mode: 0644 - notify: reload interfaces - - name: Set up interfaces template: dest: /etc/network/interfaces @@ -45,6 +31,16 @@ mode: 0644 notify: reload interfaces +- name: Set up fabric and loopback interfaces + template: + dest: '/etc/network/interfaces.d/{{ item }}' + src: '{{ item }}.j2' + mode: 0644 + notify: reload interfaces + loop: + - fabric.intf + - loopback.intf + - include_tasks: mgmt.yml - include_tasks: sdn.yml diff --git a/templates/fabric.intf.j2 b/templates/fabric.intf.j2 index ce46441..6f030eb 100644 --- a/templates/fabric.intf.j2 +++ b/templates/fabric.intf.j2 @@ -1,6 +1,6 @@ -{% for iface in hostvars[inventory_hostname].interfaces | selectattr('name', 'match', '^lan') %} +{% for iface in interfaces | selectattr('name', 'match', '^lan') %} auto {{ iface.name }} iface {{ iface.name }} mtu 9216 -{% endfor %} \ No newline at end of file +{% endfor %}