Consolidate interface setup for debian and proxmox roles

This commit is contained in:
Timotej Lazar 2023-07-20 13:46:13 +02:00
parent 8171f16f18
commit a324da076b
5 changed files with 9 additions and 23 deletions

View file

@ -1,22 +0,0 @@
source /etc/network/interfaces.d/*
# Management VRF and link.
auto mgmt
iface mgmt
address 127.0.0.1/8
address ::1/128
vrf-table auto
{% for iface in hostvars[inventory_hostname].interfaces | selectattr('name', 'match', '^mgmt') | selectattr('ip_addresses') %}
auto {{ iface.name }}
iface {{ iface.name }}
vrf mgmt
{% for ip in iface.ip_addresses %}
address {{ ip.address }}
{% set gw = query('netbox.netbox.nb_lookup', 'ip-addresses', api_filter=('tag=gateway parent=' + ip.address))|first %}
{% if gw is defined %}
gateway {{ gw.value.address | ipaddr('address') }}
{% endif %}
{% endfor %}
{% endfor %}

View file

@ -1,6 +0,0 @@
{% set iface_lo = hostvars[inventory_hostname].interfaces | selectattr('name', 'equalto', 'lo') | first %}
auto lo
iface lo inet loopback
{% for ip in iface_lo.ip_addresses %}
address {{ ip.address }}
{% endfor %}

View file

@ -13,6 +13,13 @@
apt_repository:
repo: 'deb http://download.proxmox.com/debian/pve {{ ansible_distribution_release }} pve-no-subscription'
- name: Set up loopback interface
template:
dest: /etc/network/interfaces.d/loopback.intf
src: loopback.intf.j2
mode: 0644
notify: reload interfaces
- include_tasks: mgmt.yml
- include_tasks: sdn.yml

View file

@ -1,5 +0,0 @@
{% for name in hwaddr %}
{% for addr in hwaddr[name] %}
SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="{{ addr }}", NAME="{{ name }}{{ loop.index0 }}"
{% endfor %}
{% endfor %}

View file

@ -1,16 +0,0 @@
auto lo
iface lo inet loopback
auto mgmt
iface mgmt
address 127.0.0.1/8
address ::1/128
vrf-table auto
auto {{ iface_mgmt }}
iface {{ iface_mgmt }}
vrf mgmt
address {{ ansible_host }}/{{ mgmt_gw | ipaddr('prefix') }}
gateway {{ mgmt_gw | ipaddr('address') }}
source /etc/network/interfaces.d/*