Skip to content

Commit e99b6e4

Browse files
committed
fixup! Adds support for cold migration to drain script
1 parent 969de52 commit e99b6e4

File tree

5 files changed

+34
-4
lines changed

5 files changed

+34
-4
lines changed

etc/kayobe/ansible/nova-compute-drain.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@
99
tasks:
1010
- include_role:
1111
name: nova-compute-drain
12+
run_once: true

etc/kayobe/ansible/roles/nova-compute-drain/tasks/cold-migrate.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,5 @@
3434
delegate_to: "{{ nova_compute_drain_delegate_host }}"
3535
vars:
3636
ansible_host: "{{ hostvars[nova_compute_drain_delegate_host].ansible_host }}"
37-
instance_uuid: "{{ item.ID | default }}"
3837
rescue:
3938
- meta: noop

etc/kayobe/ansible/roles/nova-compute-drain/tasks/live-migrate.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
delegate_to: "{{ nova_compute_drain_delegate_host }}"
1212
environment: "{{ openstack_auth_env }}"
1313
vars:
14-
instance_uuid: "{{ item.ID | default }}"
1514
ansible_host: "{{ hostvars[nova_compute_drain_delegate_host].ansible_host }}"
1615
register: result
1716
failed_when:
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
---
2+
- include_tasks:
3+
name: setup.yml
4+
5+
- include_tasks:
6+
name: instance-info.yml
7+
8+
- include_tasks:
9+
name: live-migrate.yml
10+
loop: "{{ nova_compute_drain_instance_info | selectattr('Status', 'equalto', 'ACTIVE') | list }}"
11+
loop_control:
12+
label: "{{ item.ID | default }}"
13+
vars:
14+
instance_uuid: "{{ item.ID | default }}"
15+
16+
- include_tasks:
17+
name: cold-migrate.yml
18+
loop: "{{ nova_compute_drain_instance_info | selectattr('Status', 'equalto', 'SHUTOFF') | list }}"
19+
loop_control:
20+
label: "{{ item.ID | default }}"
21+
vars:
22+
instance_uuid: "{{ item.ID | default }}"
23+
24+
- include_tasks:
25+
name: instance-info.yml
26+
27+
- name: Fail if there are instances still on the host
28+
fail:
29+
msg: >
30+
Instances still on {{ inventory_hostname }}: {{ instances.stdout | from_json }}
31+
when:
32+
- nova_compute_migration_fatal | bool
33+
- nova_compute_drain_instance_info | length > 0

etc/kayobe/ansible/roles/nova-compute-drain/tasks/setup.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
- setuptools
99
state: latest
1010
virtualenv_command: /usr/bin/python3.6 -m venv
11-
run_once: true
1211
delegate_to: "{{ nova_compute_drain_delegate_host }}"
1312
vars:
1413
# NOTE: Without this, the delegate ansible_host variable will not
@@ -21,7 +20,6 @@
2120
name:
2221
- python-openstackclient
2322
extra_args: "{% if pip_upper_constraints_file %}-c {{ pip_upper_constraints_file }}{% endif %}"
24-
run_once: true
2523
delegate_to: "{{ nova_compute_drain_delegate_host }}"
2624
vars:
2725
# NOTE: Without this, the delegate's ansible_host variable will not

0 commit comments

Comments
 (0)