blob: 549cb3334326ba28d35f6f0adef5d9086d5af4fd (
plain)
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
|
---
- name: Check Libvirt version compatibility
when: enable_nova_libvirt_container | bool and (groups[service.group] | length) > 0
vars:
service_name: "nova-libvirt"
service: "{{ nova_cell_services[service_name] }}"
tags: nova-libvirt-version-check
block:
- name: Get new Libvirt version
become: true
kolla_container:
action: "start_container"
command: "libvirtd --version"
common_options: "{{ docker_common_options }}"
container_engine: "{{ kolla_container_engine }}"
detach: false
environment:
KOLLA_CONFIG_STRATEGY: "{{ config_strategy }}"
image: "{{ service.image }}"
name: "libvirt_version_check"
restart_policy: oneshot
remove_on_exit: true
register: libvirt_version_new
failed_when: false
check_mode: false
run_once: true
delegate_to: "{{ groups[service.group] | first }}"
- name: Cache new Libvirt version
ansible.builtin.set_fact:
libvirt_new_version: "{{ libvirt_version_new.stdout | regex_search('[0-9]+\\.[0-9]+\\.[0-9]+') }}"
run_once: true
delegate_facts: true
delegate_to: "{{ groups[service.group] | first }}"
- name: Get nova_libvirt image info
ansible.builtin.include_role:
name: service-image-info
run_once: true
- name: Get container facts
become: true
kolla_container_facts:
action: get_containers
container_engine: "{{ kolla_container_engine }}"
name:
- "{{ service.container_name }}"
register: container_facts_per_host
when: inventory_hostname in groups[service.group]
- name: Get current Libvirt version
any_errors_fatal: true
become: true
ansible.builtin.command: "{{ kolla_container_engine }} exec {{ service.container_name }} libvirtd --version"
register: libvirt_version_current_results
changed_when: false
when:
- container_facts_per_host is not skipped
- container_facts_per_host.containers[service.container_name] is defined
- (hostvars[groups[service.group] | first].service_image_info.images | default([]) | length) > 0
- container_facts_per_host.containers[service.container_name].Image
!= hostvars[groups[service.group] | first].service_image_info.images[0].Id
- name: Check that the new Libvirt version is >= current
any_errors_fatal: true
vars:
current_version: "{{ libvirt_version_current_results.stdout | regex_search('[0-9]+\\.[0-9]+\\.[0-9]+') }}"
new_version: "{{ hostvars[groups[service.group] | first].libvirt_new_version }}"
ansible.builtin.assert:
that: "{{ new_version is version(current_version, '>=', strict=true) }}"
fail_msg: >
It looks like you're about to downgrade Libvirt in the nova_libvirt container from
version {{ current_version }} to version {{ new_version }}. If you're absolutely certain
that you want to do this, please skip the tag `nova-libvirt-version-check`.
success_msg: >
Libvirt version check successful: target {{ new_version }} >= current {{ current_version }}.
when: libvirt_version_current_results is not skipped
|