From cd539d5c8751fd3ee3b10df996bba2e5639d46fa Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Mon, 23 Dec 2019 01:31:19 +0100 Subject: gh-gnocchi networking --- chaos-at-home/ch-gnocchi.yml | 7 +++- inventory/host_vars/ch-gnocchi.yml | 80 ++++++++++++++++++++++---------------- 2 files changed, 52 insertions(+), 35 deletions(-) diff --git a/chaos-at-home/ch-gnocchi.yml b/chaos-at-home/ch-gnocchi.yml index b4c1ef21..2ab51770 100644 --- a/chaos-at-home/ch-gnocchi.yml +++ b/chaos-at-home/ch-gnocchi.yml @@ -9,5 +9,8 @@ - role: installer/debian - role: installer/openbsd post_tasks: - - pause: - prompt: "{{ __interface_configs__ }}" + # you need to reboot for changes to take effect + - name: install network interface config + copy: + dest: /etc/network/interfaces + content: "{{ __interface_configs__ }}" diff --git a/inventory/host_vars/ch-gnocchi.yml b/inventory/host_vars/ch-gnocchi.yml index 278ef9f4..35527e2d 100644 --- a/inventory/host_vars/ch-gnocchi.yml +++ b/inventory/host_vars/ch-gnocchi.yml @@ -19,50 +19,64 @@ installer_lvm: fs: ext4 -__interfaces__: + +__interface_zones__: enp1s0: - zones: - lan: - type: manual - svc: - type: manual + - lan + - svc enp2s0: - zones: - magenta: - type: manual + - magenta enp3s0: - zones: - mgmt: - type: static - address: "{{ network_zones.mgmt.prefix | ipaddr(network_zones.mgmt.offsets[inventory_hostname]) | ipaddr('address') }}" - netmask: "{{ network_zones.mgmt.prefix | ipaddr('netmask') }}" - iot: - type: manual + - name: mgmt + prefix: "{{ network_zones.mgmt.prefix | ipaddr(network_zones.mgmt.offsets[inventory_hostname]) }}" + - iot + + +__interface_zones_yaml__: | + {% for interface in __interface_zones__.keys() %} + {% for zone in __interface_zones__[interface] %} + {% if zone is mapping %} + {{ zone.name }}: + interfaces: + - {{ interface }}.{{ network_zones[zone.name].vlan }} + prefix: {{ zone.prefix }} + {% else %} + {{ zone }}: + interfaces: + - {{ interface }}.{{ network_zones[zone].vlan }} + {% endif %} + {% endfor %} + {% endfor %} + + +vm_host: + network: + bridges: "{{ __interface_zones_yaml__ | from_yaml }}" __interface_configs__: | - {% for interface in __interfaces__.keys() %} - ## - ## /etc/network/interfaces.d/{{ interface }} - ## + # This file describes the network interfaces available on your system + # and how to activate them. For more information, see interfaces(5). + + # The loopback network interface + auto lo + iface lo inet loopback + {% for interface in __interface_zones__.keys() %} + + auto {{ interface }} iface {{ interface }} inet manual + {% for zone in __interface_zones__[interface] %} - {% for zone in __interfaces__[interface].zones.keys() %} - + {% if zone is mapping %} + auto {{ interface }}.{{ network_zones[zone.name].vlan }} + iface {{ interface }}.{{ network_zones[zone.name].vlan }} inet manual + {% else %} auto {{ interface }}.{{ network_zones[zone].vlan }} iface {{ interface }}.{{ network_zones[zone].vlan }} inet manual - - auto br-{{ zone }} - iface br-{{ zone }} inet {{ __interfaces__[interface].zones[zone].type }} - bridge_ports {{ interface }}.{{ network_zones[zone].vlan }} - bridge_stp off - bridge_waitport 0 - bridge_fd 0 - {% if __interfaces__[interface].zones[zone].type == 'static' %} - address {{ __interfaces__[interface].zones[zone].address }} - netmask {{ __interfaces__[interface].zones[zone].netmask }} {% endif %} - {% endfor %} {% endfor %} + + + source /etc/network/interfaces.d/* -- cgit v1.2.3