New implementation of network interfaces

Combine interfaces and network_ether_interfaces into one common
variable network_interfaces. Provisioning uses format:

network_interfaces:
  - device: device name eg. vio0 or eth0
    vlan: vlan id for this interface
    mac: mac address for interface (optional)

Additionally network role will use more settings to configure
interface.
This commit is contained in:
Timo Makinen 2020-08-27 17:42:07 +00:00
parent 78c9a2eaf1
commit c80eca3d85
11 changed files with 46 additions and 19 deletions

View file

@ -1,3 +1,6 @@
---
interfaces: [[20, "52:54:00:ac:dc:0b"]]
vmhost: vmhost02.home.foo.sh
network_interfaces:
- device: eth0
vlan: 20
mac: "52:54:00:ac:dc:0b"

View file

@ -1,3 +1,6 @@
---
interfaces: [[20, "52:54:00:ac:dc:18"]]
vmhost: vmhost02.home.foo.sh
network_interfaces:
- device: eth0
vlan: 20
mac: 52:54:00:ac:dc:18

View file

@ -1,3 +1,8 @@
---
interfaces: [[20, "52:54:00:ac:dc:01"], [103]]
vmhost: vmhost01.home.foo.sh
network_interfaces:
- device: vio0
vlan: 20
mac: 52:54:00:ac:dc:01
- device: vio1
vlan: 103

View file

@ -1,6 +1,9 @@
---
interfaces: [[20, "52:54:00:ac:dc:1f"]]
vmhost: vmhost01.home.foo.sh
network_interfaces:
- device: eth0
vlan: 20
mac: 52:54:00:ac:dc:1f
datadisks:
- 10

View file

@ -1,3 +1,6 @@
---
interfaces: [[20, "52:54:00:ac:dc:20"]]
vmhost: vmhost02.home.foo.sh
network_interfaces:
- device: eth0
vlan: 20
mac: 52:54:00:ac:dc:20

View file

@ -1,3 +1,6 @@
---
interfaces: [[20, "52:54:00:ac:dc:27"]]
vmhost: vmhost01.home.foo.sh
network_interfaces:
- device: vio0
vlan: 20
mac: 52:54:00:ac:dc:27

View file

@ -1,3 +1,6 @@
---
interfaces: [[20, "52:54:00:ac:dc:15"]]
vmhost: vmhost01.home.foo.sh
network_interfaces:
- device: eth0
vlan: 20
mac: 52:54:00:ac:dc:15

View file

@ -1,12 +1,13 @@
---
interfaces: [[20, "52:54:00:ac:dc:0d"], [102]]
vmhost: vmhost01.home.foo.sh
network_ether_interfaces:
network_interfaces:
- device: vio0
vlan: 20
mac: 52:54:00:ac:dc:0d
ipaddr: 172.20.21.13
netmask: 255.255.252.0
- device: vio1
vlan: 102
proto: none
# kludge advskew values for carps

View file

@ -1,12 +1,13 @@
---
interfaces: [[20, "52:54:00:ac:dc:0e"], [102]]
vmhost: vmhost02.home.foo.sh
network_ether_interfaces:
network_interfaces:
- device: vio0
vlan: 20
mac: 52:54:00:ac:dc:0e
ipaddr: 172.20.21.14
netmask: 255.255.252.0
- device: vio1
vlan: 102
proto: none
carp8_advskew: 128

View file

@ -24,11 +24,13 @@
{% endif %}
virt_install_network: >-
{% for item in interfaces %}
{% if item[1] is defined %}
--network bridge=br{{ item[0] }},mac={{ item[1] }},model=virtio
{% for item in network_interfaces %}
{% if item.vlan is defined %}
{% if item.mac is defined %}
--network bridge=br{{ item.vlan }},mac={{ item.mac }},model=virtio
{% else %}
--network bridge=br{{ item[0] }},model=virtio
--network bridge=br{{ item.vlan }},model=virtio
{% endif %}
{% endif %}
{% endfor %}

View file

@ -7,7 +7,7 @@
mode: 0600
owner: root
group: "{{ ansible_wheel }}"
with_items: "{{ network_ether_interfaces }}"
with_items: "{{ network_interfaces }}"
notify: restart network
- block: