[Baremetal] Provide networking for Ubuntu nodes 99/60799/37
authorManuel Buil <mbuil@suse.com>
Thu, 9 Aug 2018 15:07:23 +0000 (17:07 +0200)
committerManuel Buil <mbuil@suse.com>
Tue, 6 Nov 2018 13:16:25 +0000 (14:16 +0100)
When deploying baremetal, the traffic should be segmented using the
different interfaces instead of through vlans. All the config is done
based on idf and pdf information.

When doing non-baremetal, opnfv and nodes get the same config. When
doing baremetal, opnfv and nodes get a different network config

Change-Id: I23aa576bc782c7c69d511a5558827110c37b558a
Signed-off-by: Manuel Buil <mbuil@suse.com>
xci/playbooks/roles/bootstrap-host/tasks/network_debian.yml
xci/playbooks/roles/bootstrap-host/vars/main.yml [new file with mode: 0644]

index f2a138f..46f6e81 100644 (file)
     - { name: "br-storage", bridge_ports: "{{ ansible_local.xci.network.xci_interface }}.20", network: "{{ host_info[inventory_hostname].storage }}" }
   loop_control:
     label: "{{ item.name }}"
+  when: baremetal | bool != true
+
+
+- name: "Configure baremetal networking for blade: {{ inventory_hostname }}"
+  template:
+    src: "{{ installer_type }}/debian.interface.j2"
+    dest: "/etc/network/interfaces.d/{{ item.name }}.cfg"
+  with_items:
+    - { name: "{{ admin_interface }}", network: "{{ host_info[inventory_hostname].admin }}" }
+    - { name: "{{ mgmt_interface }}", vlan_id: "{{ (mgmt_vlan == 'native') | ternary(omit, mgmt_vlan) }}" }
+    - { name: "{{ storage_interface }}", vlan_id: "{{ (storage_vlan == 'native') | ternary(omit, storage_vlan) }}" }
+    - { name: "{{ public_interface }}", vlan_id: "{{ (public_vlan == 'native') | ternary(omit, public_vlan) }}" }
+    - { name: "{{ private_interface }}", vlan_id: "{{ (private_vlan == 'native') | ternary(omit, private_vlan) }}" }
+    - { name: "br-mgmt", bridge_ports: "{{ mgmt_interface }}", network: "{{ host_info[inventory_hostname].mgmt }}" }
+    - { name: "br-vxlan", bridge_ports: "{{ private_interface }}", network: "{{ host_info[inventory_hostname].private }}" }
+    - { name: "br-vlan", bridge_ports: "{{ public_interface }}", network: "{{ host_info[inventory_hostname].public }}" }
+    - { name: "br-storage", bridge_ports: "{{ storage_interface }}", network: "{{ host_info[inventory_hostname].storage }}" }
+  loop_control:
+    label: "{{ item.name }}"
+  when:
+    -  baremetal | bool == true
+    - "'opnfv' not in inventory_hostname"
+
+- name: "Configure baremetal networking for VM: {{ inventory_hostname }}"
+  template:
+    src: "{{ installer_type }}/debian.interface.j2"
+    dest: "/etc/network/interfaces.d/{{ item.name }}.cfg"
+  with_items:
+    - { name: "{{ mgmt_interface }}", vlan_id: "{{ (mgmt_vlan == 'native') | ternary(omit, mgmt_vlan) }}" }
+    - { name: "{{ public_interface }}", vlan_id: "{{ (public_vlan == 'native') | ternary(omit, public_vlan) }}" }
+    - { name: "br-mgmt", bridge_ports: "{{ mgmt_interface }}", network: "{{ host_info[inventory_hostname].mgmt }}" }
+    - { name: "br-vlan", bridge_ports: "{{ public_interface }}", network: "{{ host_info[inventory_hostname].public }}" }
+  loop_control:
+    label: "{{ item.name }}"
+  when:
+    - baremetal | bool == true
+    - "'opnfv' in inventory_hostname"
 
 - name: restart network service
-  shell: "/sbin/ifconfig {{ ansible_local.xci.network.xci_interface }} 0 && /sbin/ifdown -a && /sbin/ifup -a"
+  shell: "/sbin/ip addr flush dev {{ item }} && /sbin/ifdown -a && /sbin/ifup -a"
   async: 15
   poll: 0
+  with_items:
+    - "{{ public_interface }}"
+    - "{{ mgmt_interface }}"
diff --git a/xci/playbooks/roles/bootstrap-host/vars/main.yml b/xci/playbooks/roles/bootstrap-host/vars/main.yml
new file mode 100644 (file)
index 0000000..1730ad5
--- /dev/null
@@ -0,0 +1,70 @@
+---
+# admin network information
+admin_mac: "{{ host_info[inventory_hostname].admin.mac_address }}"
+admin_interface: >-
+  {% for x in (ansible_interfaces | map('regex_replace', '-', '_') | map('regex_replace', '^', 'ansible_') | map('extract', hostvars[inventory_hostname]) |  selectattr('macaddress','defined')) -%}
+  {%- if x.macaddress == admin_mac -%}
+  {%- if admin_vlan == 'native' -%}
+  {{ x.device }}
+  {%- else -%}
+  {{ x.device }}.{{ admin_vlan }}
+  {%- endif -%}
+  {%- endif -%}
+  {%- endfor -%}
+admin_vlan: "{{ host_info[inventory_hostname].admin.vlan }}"
+
+# mgmt network information
+mgmt_mac: "{{ host_info[inventory_hostname].mgmt.mac_address }}"
+mgmt_interface: >-
+  {% for x in (ansible_interfaces | map('regex_replace', '-', '_') | map('regex_replace', '^', 'ansible_') | map('extract', hostvars[inventory_hostname]) |  selectattr('macaddress','defined')) -%}
+  {%- if x.macaddress == mgmt_mac -%}
+  {%- if mgmt_vlan == 'native' -%}
+  {{ x.device }}
+  {%- else -%}
+  {{ x.device }}.{{ mgmt_vlan }}
+  {%- endif -%}
+  {%- endif -%}
+  {%- endfor -%}
+mgmt_vlan: "{{ host_info[inventory_hostname].mgmt.vlan }}"
+
+# storage network information
+storage_mac: "{{ host_info[inventory_hostname].storage.mac_address }}"
+storage_interface: >-
+  {%- for x in (ansible_interfaces | map('regex_replace', '-', '_') | map('regex_replace', '^', 'ansible_') | map('extract', hostvars[inventory_hostname]) |  selectattr('macaddress','defined')) -%}
+  {%- if x.macaddress == storage_mac -%}
+  {%- if storage_vlan == 'native' -%}
+  {{ x.device }}
+  {%- else -%}
+  {{ x.device }}.{{ storage_vlan }}
+  {%- endif -%}
+  {%- endif -%}
+  {%- endfor -%}
+storage_vlan: "{{ host_info[inventory_hostname].storage.vlan }}"
+
+# public vlan netwrk information
+public_mac: "{{ host_info[inventory_hostname].public.mac_address }}"
+public_interface: >-
+  {%- for x in (ansible_interfaces | map('regex_replace', '-', '_') | map('regex_replace', '^', 'ansible_') | map('extract', hostvars[inventory_hostname]) |  selectattr('macaddress','defined')) -%}
+  {%- if x.macaddress == public_mac -%}
+  {%- if public_vlan == 'native' -%}
+  {{ x.device }}
+  {%- else -%}
+  {{ x.device }}.{{ public_vlan }}
+  {%- endif -%}
+  {%- endif -%}
+  {%- endfor -%}
+public_vlan: "{{ host_info[inventory_hostname].public.vlan }}"
+
+# private vxlan network information
+private_mac: "{{ host_info[inventory_hostname].private.mac_address }}"
+private_interface: >-
+  {%- for x in (ansible_interfaces | map('regex_replace', '-', '_') | map('regex_replace', '^', 'ansible_') | map('extract', hostvars[inventory_hostname]) |  selectattr('macaddress','defined')) -%}
+  {%- if x.macaddress == private_mac -%}
+  {%- if private_vlan == 'native' -%}
+  {{ x.device }}
+  {%- else -%}
+  {{x.device}}.{{ private_vlan }}
+  {%- endif -%}
+  {%- endif -%}
+  {%- endfor -%}
+private_vlan: "{{ host_info[inventory_hostname].private.vlan }}"