1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
|
---
# SPDX-license-identifier: Apache-2.0
##############################################################################
# Copyright (c) 2018 SUSE LINUX GmbH.
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Apache License, Version 2.0
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
- name: configure modules
lineinfile:
dest: /etc/modules
state: present
create: yes
line: "8021q"
- name: add modules
modprobe:
name: 8021q
state: present
- name: ensure interfaces.d folder is empty
file:
state: "{{ item }}"
path: "/etc/network/interfaces.d"
with_items:
- absent
- directory
- name: Ensure /etc/interfaces can source additional files
copy:
content: |
auto lo
iface lo inet loopback
source /etc/network/interfaces.d/*.cfg
dest: "/etc/network/interfaces"
- name: "Configure networking for {{ inventory_hostname }}"
template:
src: "{{ installer_type }}/debian.interface.j2"
dest: "/etc/network/interfaces.d/{{ item.name }}.cfg"
with_items:
- { name: "{{ ansible_local.xci.network.xci_interface }}" }
- { name: "{{ ansible_local.xci.network.xci_interface }}.10", vlan_id: 10 }
- { name: "{{ ansible_local.xci.network.xci_interface }}.30", vlan_id: 30 }
- { name: "{{ ansible_local.xci.network.xci_interface }}.20", vlan_id: 20 }
- { name: "br-mgmt", bridge_ports: "{{ ansible_local.xci.network.xci_interface }}.10", network: "{{ host_info[inventory_hostname].mgmt }}" }
- { name: "br-vxlan", bridge_ports: "{{ ansible_local.xci.network.xci_interface }}.30", network: "{{ host_info[inventory_hostname].private }}" }
- { name: "br-vlan", bridge_ports: "{{ ansible_local.xci.network.xci_interface }}", network: "{{ host_info[inventory_hostname].public }}" }
- { 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/ip addr flush dev {{ item }} && /sbin/ifdown -a && /sbin/ifup -a"
async: 15
poll: 0
with_items:
- "{{ public_interface }}"
- "{{ mgmt_interface }}"
|