Debian Codegraph @

tools/ovn_migration/migrate-to-ovn.yml

raw symbols SCIP
1 # Migrate a Neutron deployment using ML2/OVS to OVN.
2 #
3 # See hosts-sample for expected contents of the ansible inventory.
4
5 ---
6 - hosts: compute
7 remote_user: "{{ remote_user }}"
8 become: true
9 tasks:
10 - name: Ensure OVN packages are installed on compute nodes.
11 yum:
12 name: openvswitch-ovn-host
13 state: present
14 # TODO to make ansible-lint happy, all of these commands should be conditionally run
15 # only if the config value needs to be changed.
16 - name: Configure ovn-encap-type.
17 command: "ovs-vsctl set open . external_ids:ovn-encap-type=geneve"
18 changed_when: false
19 - name: Configure ovn-encap-ip.
20 command: "ovs-vsctl set open . external_ids:ovn-encap-ip={{ ovn_encap_ip }}"
21 changed_when: false
22 - name: Configure ovn-remote.
23 command: "ovs-vsctl set open . external_ids:ovn-remote=tcp:{{ ovn_db_ip }}:6642"
24 changed_when: false
25 # TODO We could discover the appropriate value for ovn-bridge-mappings based on
26 # the openvswitch agent configuration instead of requiring it to be configured
27 # in the inventory.
28 - name: Configure ovn-bridge-mappings.
29 command: "ovs-vsctl set open . external_ids:ovn-bridge-mappings={{ ovn_bridge_mappings }}"
30 changed_when: false
31 - name: Get hostname
32 command: hostname -f
33 register: hostname
34 check_mode: no
35 changed_when: false
36 - name: Set host name
37 command: "ovs-vsctl set Open_vSwitch . external-ids:hostname={{ hostname.stdout }}"
38 changed_when: false
39 # TODO ansible has an "iptables" module, but it does not allow you specify a "rule number"
40 # which we require here.
41 - name: Open Geneve UDP port for tunneling.
42 command: iptables -I INPUT 10 -m state --state NEW -p udp --dport 6081 -j ACCEPT
43 changed_when: false
44 - name: Persist our iptables changes after a reboot
45 shell: iptables-save > /etc/sysconfig/iptables.save
46 args:
47 creates: /etc/sysconfig/iptables.save
48 # TODO Remove this once the metadata API is supported.
49 # https://bugs.launchpad.net/networking-ovn/+bug/1562132
50 - name: Force config drive until the metadata API is supported.
51 ini_file:
52 dest: /etc/nova/nova.conf
53 section: DEFAULT
54 option: force_config_drive
55 value: true
56 - name: Restart nova-compute service to reflect force_config_drive value.
57 systemd:
58 name: openstack-nova-compute
59 state: restarted
60 enabled: yes
61
62 - hosts: controller
63 remote_user: "{{ remote_user }}"
64 become: true
65 tasks:
66 - name: Ensure OVN packages are installed on the central OVN host.
67 when: ovn_central is defined
68 yum:
69 name: openvswitch-ovn-central
70 state: present
71 # TODO Set up SSL for OVN databases
72 # TODO ansible has an "iptables" module, but it does not allow you specify a "rule number"
73 # which we require here.
74 - name: Open OVN database ports.
75 command: "iptables -I INPUT 10 -m state --state NEW -p tcp --dport {{ item }} -j ACCEPT"
76 with_items: [ 6641, 6642 ]
77 changed_when: False
78 - name: Persist our iptables changes after a reboot
79 shell: iptables-save > /etc/sysconfig/iptables.save
80 args:
81 creates: /etc/sysconfig/iptables.save
82 # TODO Integrate HA support for the OVN control services.
83 - name: Start ovn-northd and the OVN databases.
84 when: ovn_central is defined
85 systemd:
86 name: ovn-northd
87 state: started
88 enabled: yes
89 - name: Enable remote access to the northbound database.
90 command: "ovn-nbctl set-connection ptcp:6641:{{ ovn_db_ip }}"
91 when: ovn_central is defined
92 changed_when: False
93 - name: Enable remote access to the southbound database.
94 command: "ovn-sbctl set-connection ptcp:6642:{{ ovn_db_ip }}"
95 when: ovn_central is defined
96 changed_when: False
97 - name: Update Neutron configuration files
98 ini_file: dest={{ item.dest }} section={{ item.section }} option={{ item.option }} value={{ item.value }}
99 with_items:
100 - { dest: '/etc/neutron/neutron.conf', section: 'DEFAULT', option: 'service_plugins', value: 'qos,ovn-router' }
101 - { dest: '/etc/neutron/neutron.conf', section: 'DEFAULT', option: 'notification_drivers', value: 'ovn-qos' }
102 - { dest: '/etc/neutron/plugins/ml2/ml2_conf.ini', section: 'ml2', option: 'mechanism_drivers', value: 'ovn' }
103 - { dest: '/etc/neutron/plugins/ml2/ml2_conf.ini', section: 'ml2', option: 'type_drivers', value: 'geneve,vxlan,vlan,flat' }
104 - { dest: '/etc/neutron/plugins/ml2/ml2_conf.ini', section: 'ml2', option: 'project_network_types', value: 'geneve' }
105 - { dest: '/etc/neutron/plugins/ml2/ml2_conf.ini', section: 'ml2_type_geneve', option: 'vni_ranges', value: '1:65536' }
106 - { dest: '/etc/neutron/plugins/ml2/ml2_conf.ini', section: 'ml2_type_geneve', option: 'max_header_size', value: '38' }
107 - { dest: '/etc/neutron/plugins/ml2/ml2_conf.ini', section: 'ovn', option: 'ovn_nb_connection', value: '"tcp:{{ ovn_db_ip }}:6641"' }
108 - { dest: '/etc/neutron/plugins/ml2/ml2_conf.ini', section: 'ovn', option: 'ovn_sb_connection', value: '"tcp:{{ ovn_db_ip }}:6642"' }
109 - { dest: '/etc/neutron/plugins/ml2/ml2_conf.ini', section: 'ovn', option: 'ovsdb_connection_timeout', value: '180' }
110 - { dest: '/etc/neutron/plugins/ml2/ml2_conf.ini', section: 'ovn', option: 'neutron_sync_mode', value: 'repair' }
111 - { dest: '/etc/neutron/plugins/ml2/ml2_conf.ini', section: 'ovn', option: 'ovn_l3_mode', value: 'true' }
112 - { dest: '/etc/neutron/plugins/ml2/ml2_conf.ini', section: 'ovn', option: 'vif_type', value: 'ovs' }
113 - name: Note that API downtime begins now.
114 debug:
115 msg: NEUTRON API DOWNTIME STARTING NOW FOR THIS HOST
116 - name: Shut down neutron-server so that we can begin data sync to OVN.
117 systemd:
118 name: neutron-server
119 state: stopped
120
121 - hosts: controller
122 remote_user: "{{ remote_user }}"
123 become: true
124 tasks:
125 - name: Sync Neutron state to OVN.
126 when: ovn_central is defined
127 command: neutron-ovn-db-sync-util --config-file /etc/neutron/neutron.conf --config-file /etc/neutron/plugins/ml2/ml2_conf.ini
128
129 - hosts: overcloud
130 remote_user: "{{ remote_user }}"
131 become: true
132 tasks:
133 - name: Note that data plane imact starts now.
134 debug:
135 msg: DATA PLANE IMPACT BEGINS NOW.
136 - name: Stop metadata, DHCP, L3 and openvswitch agent if needed.
137 systemd: name={{ item.name }} state={{ item.state }} enabled=no
138 with_items:
139 - { name: 'neutron-metadata-agent', state: 'stopped' }
140 - { name: 'neutron-dhcp-agent', state: 'stopped' }
141 - { name: 'neutron-l3-agent', state: 'stopped' }
142 - { name: 'neutron-openvswitch-agent', state: 'stopped' }
143
144 - hosts: compute
145 remote_user: "{{ remote_user }}"
146 become: true
147 tasks:
148 - name: Note that data plane is being restored.
149 debug:
150 msg: DATA PLANE IS NOW BEING RESTORED.
151 - name: Delete br-tun as it is no longer used.
152 command: "ovs-vsctl del-br br-tun"
153 changed_when: false
154 - name: Reset OpenFlow protocol version before ovn-controller takes over.
155 with_items: [ br-int, br-ex ]
156 command: "ovs-vsctl set Bridge {{ item }} protocols=[]"
157 ignore_errors: True
158 changed_when: false
159 - name: Start ovn-controller.
160 systemd:
161 name: ovn-controller
162 state: started
163 enabled: yes
164
165 - hosts: controller
166 remote_user: "{{ remote_user }}"
167 become: true
168 tasks:
169 # TODO The sync util scheduling gateway routers depends on this patch:
170 # https://review.openstack.org/#/c/427020/
171 # If the patch is not merged, this command is harmless, but the gateway
172 # routers won't get scheduled until later when neutron-server starts.
173 - name: Schedule gateway routers by running the sync util.
174 when: ovn_central is defined
175 command: neutron-ovn-db-sync-util --config-file /etc/neutron/neutron.conf --config-file /etc/neutron/plugins/ml2/ml2_conf.ini
176 changed_when: false
177 - name: Configure node for hosting gateway routers for external connectivity.
178 command: "ovs-vsctl set open . external_ids:ovn-cms-options=enable-chassis-as-gw"
179 changed_when: false
180
181 - hosts: overcloud
182 remote_user: "{{ remote_user }}"
183 become: true
184 tasks:
185 # TODO Make this smarter so that it only deletes net namespaces that were
186 # # created by neutron. In the simple case, this is fine, but will break
187 # # once containers are in use on the overcloud.
188 - name: Delete network namespaces.
189 command: ip -all netns delete
190 changed_when: false
191
192 - hosts: controller
193 remote_user: "{{ remote_user }}"
194 become: true
195 tasks:
196 - name: Note that the Neutron API is coming back online.
197 debug:
198 msg: THE NEUTRON API IS NOW BEING RESTORED.
199 - name: Start neutron-server.
200 systemd:
201 name: neutron-server
202 state: started
203
204 # TODO In our grenade script we had to restart rabbitmq. Is that needed?