-
Notifications
You must be signed in to change notification settings - Fork 16
/
prepare_nic_configs.yml
174 lines (145 loc) · 6.62 KB
/
prepare_nic_configs.yml
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
---
- hosts: localhost
vars:
undercloud_host: "{{ groups.undercloud|first }}"
tasks:
- name: get subnet mask
shell: |
echo {{ cidr }} | cut -d '/' -f2
register: prefix
- name: set subnet mask
set_fact:
subnet_mask: "{{ prefix.stdout }}"
- block:
- name: set fact for rhel7 ifaces (r640)
set_fact:
rhel7_interfaces: "{{ (undercloud_hostname.split('-')[0] == 'f04') | ternary('rhel7_interfaces_f04', 'rhel7_interfaces') }}"
when: machine_type == 'r640'
- name: set fact for rhel8 ifaces (r640)
set_fact:
rhel8_interfaces: "{{ (undercloud_hostname.split('-')[0] == 'f04') | ternary('rhel8_interfaces_f04', 'rhel8_interfaces') }}"
when: machine_type == 'r640'
- name: set_fact iface_rhel_version
set_fact:
iface_rhel_version: "{{ (osp_release|int > 14)| ternary(rhel8_interfaces, 'rhel7_interfaces') }}"
when: machine_type == 'r640'
- name: set interfaces
set_fact:
ifaces: "{{ lab_vars['machine_types'][vendor][machine_type][iface_rhel_version] }}"
vars:
lab_vars: "{{ (lab_name == 'scale') | ternary(scale, alias) }}"
iface_rhel_version: "{{ (osp_release|int > 14)| ternary('rhel8_interfaces', 'rhel7_interfaces') }}"
when: lab_name in ['scale', 'alias'] and osp_release|int < 17
- name: set interfaces (OSP17)
set_fact:
ifaces: "{{ lab_vars['machine_types'][vendor][machine_type][iface_rhel_version] }}"
vars:
lab_vars: "{{ (lab_name == 'scale') | ternary(scale, alias) }}"
iface_rhel_version: 'rhel9_interfaces'
when: lab_name in ['scale', 'alias'] and osp_release|int == 17
- name: set interfaces for non scale/alias machines
set_fact:
ifaces: "{{ (osp_release|int > 14)| ternary(interfaces.rhel8_interfaces, interfaces.rhel7_interfaces) }}"
when: lab_name not in ['scale', 'alias'] and osp_release|int < 17
- name: interfaces is empty
fail:
msg: other lab types should specify interfaces
when: (ifaces is defined) and (ifaces|length == 0)
# br-isolated will be always first interface, followed by br-ctlplane,
# br-tenant and br-external. br-external and br-ctlplane will be shared if
# no separate nic avaialble for external interface.
- name: set control and external interfaces
set_fact:
ctlplane_interface: "{{ (ifaces|length > 1) | ternary(ifaces[1], ifaces[0]) }}"
when: ctlplane_interface is not defined
- name: set external interface
set_fact:
external_interface: "{{ (ifaces|length > 3) | ternary(ifaces[3], ctlplane_interface) }}"
when: external_interface is not defined
- name: set tenant interface
set_fact:
tenant_interface: "{{ ifaces[2] }}"
when: tenant_interface is not defined and ifaces|length > 2 and vlan_provider_network == false
- name: set isolated interface
set_fact:
isolated_interface: "{{ ifaces[0] }}"
when: isolated_interface is not defined and ifaces|length > 1
- name: set storage_interface
set_fact:
storage_interface: "{{ ifaces[0] }}"
when: storage_interface is not defined and ifaces|length > 1
- name: set dedicated vlan based provider network
set_fact:
openshift_vlan_interface: "{{ ifaces[2] }}"
when: vlan_provider_network == true and ifaces|length > 2
- name: set nic configs
set_fact:
nic_configs: "{{ ansible_user_dir }}/virt"
- name: create nic-configs directory structure in infrared format
file:
path: "{{ ansible_user_dir }}/virt/network/vlans/legacy"
state: directory
# infrared uses nic configs under 'legacy' directory for osp release version 10
- name: set nic-config path
set_fact:
nic_config_path: "{{ ansible_user_dir }}/virt/network/vlans{{ ((osp_release|int > 10) | ternary('', '/legacy')) }}"
- block:
- name: prepare network-environment.yaml.j2
template:
src: "network-environment.yaml.j2"
dest: "{{ ansible_user_dir }}/virt/network/network-environment.yaml.j2"
force: yes
- name: prepare controller.yaml.j2
template:
src: "{{ (osp_release|int > 10) | ternary('controller.yaml.j2', 'osp10_controller.yaml.j2') }}"
dest: "{{ nic_config_path }}/controller.yaml.j2"
force: yes
- name: prepare compute.yaml.j2
vars:
compute_path: "{{ (scale_compute_vms) | ternary('compute_vms.yaml.j2', 'compute.yaml.j2') }}"
template:
src: "{{ (osp_release|int > 10) | ternary(compute_path, 'osp10_compute.yaml.j2') }}"
dest: "{{ nic_config_path }}/compute.yaml.j2"
force: yes
- name: prepare ceph-storage.yaml.j2
template:
src: ceph-storage.yaml.j2
dest: "{{ nic_config_path }}/ceph-storage.yaml.j2"
force: yes
when: ceph_enabled
when: osp_release|int < 17
- block:
- name: prepare network-environment_v2.yaml.j2
template:
src: network-environment_v2.yaml.j2
dest: "{{ ansible_user_dir }}/virt/network/network-environment_v2.yaml.j2"
- name: prepare network-environment_v2.yaml.j2
template:
src: network_data_v2.yaml.j2
dest: "{{ ansible_user_dir }}/virt/network/network_data_v2.yaml.j2"
- name: prepare vip_data.yaml.j2
template:
src: vip_data.yaml.j2
dest: "{{ ansible_user_dir }}/virt/network/vip_data.yaml.j2"
- name: Create nic_config_path dir
file:
path: "~/virt/network/vlans/"
state: directory
delegate_to: undercloud
- name: prepare ceph-storage.j2
template:
src: ceph-storage.j2.j2
dest: "~/virt/network/vlans/ceph-storage.j2"
when: ceph_enabled
delegate_to: undercloud
- name: prepare compute.j2
template:
src: compute.j2.j2
dest: "~/virt/network/vlans/compute.j2"
delegate_to: undercloud
- name: prepare controller.j2
template:
src: controller.j2.j2
dest: "~/virt/network/vlans/controller.j2"
delegate_to: undercloud
when: osp_release|int == 17