aboutsummaryrefslogtreecommitdiff
path: root/ansible/roles/nova-cell/tasks/precheck.yml
blob: b0b510a5b39f48bf560c1795ad152e25385e8d9a (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
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
---
- import_role:
    name: service-precheck
  vars:
    service_precheck_services: "{{ nova_cell_services }}"
    service_name: "{{ project_name }}"

- name: Get container facts
  become: true
  kolla_container_facts:
    action: get_containers
    container_engine: "{{ kolla_container_engine }}"
    name:
      - nova_libvirt
      - nova_novncproxy
      - nova_serialproxy
      - nova_spicehtml5proxy
      - nova_ssh
  check_mode: false
  register: container_facts

- name: Checking available compute nodes in inventory
  vars:
    nova_compute_ironic: "{{ nova_cell_services['nova-compute-ironic'] }}"
  fail:
    msg: >
      At least 1 compute node required in inventory when ironic is disabled.
  when:
    - groups[nova_cell_compute_group] | length < 1
    - not nova_compute_ironic.enabled | bool

- name: Checking free port for Nova NoVNC Proxy
  vars:
    service: "{{ nova_cell_services['nova-novncproxy'] }}"
  wait_for:
    host: "{{ api_interface_address }}"
    port: "{{ nova_novncproxy_listen_port }}"
    connect_timeout: 1
    timeout: 1
    state: stopped
  when:
    - container_facts.containers['nova_novncproxy'] is not defined
    - service | service_enabled_and_mapped_to_host

- name: Checking free port for Nova Serial Proxy
  vars:
    service: "{{ nova_cell_services['nova-serialproxy'] }}"
  wait_for:
    host: "{{ api_interface_address }}"
    port: "{{ nova_serialproxy_listen_port }}"
    connect_timeout: 1
    timeout: 1
    state: stopped
  when:
    - container_facts.containers['nova_serialproxy'] is not defined
    - service | service_enabled_and_mapped_to_host

- name: Checking free port for Nova Spice HTML5 Proxy
  vars:
    service: "{{ nova_cell_services['nova-spicehtml5proxy'] }}"
  wait_for:
    host: "{{ api_interface_address }}"
    port: "{{ nova_spicehtml5proxy_listen_port }}"
    connect_timeout: 1
    timeout: 1
    state: stopped
  when:
    - container_facts.containers['nova_spicehtml5proxy'] is not defined
    - service | service_enabled_and_mapped_to_host

- name: Checking free port for Nova SSH (API interface)
  vars:
    service: "{{ nova_cell_services['nova-ssh'] }}"
  wait_for:
    host: "{{ api_interface_address }}"
    port: "{{ nova_ssh_port }}"
    connect_timeout: 1
    timeout: 1
    state: stopped
  when:
    - container_facts.containers['nova_ssh'] is not defined
    - service | service_enabled_and_mapped_to_host

- name: Checking free port for Nova SSH (migration interface)
  vars:
    service: "{{ nova_cell_services['nova-ssh'] }}"
  wait_for:
    host: "{{ migration_interface_address }}"
    port: "{{ nova_ssh_port }}"
    connect_timeout: 1
    timeout: 1
    state: stopped
  when:
    - migration_interface_address != api_interface_address
    - container_facts.containers['nova_ssh'] is not defined
    - service | service_enabled_and_mapped_to_host

- name: Checking free port for Nova Libvirt
  vars:
    service: "{{ nova_cell_services['nova-libvirt'] }}"
  wait_for:
    host: "{{ api_interface_address }}"
    port: "{{ nova_libvirt_port }}"
    connect_timeout: 1
    timeout: 1
    state: stopped
  when:
    - container_facts.containers['nova_libvirt'] is not defined
    - service | service_enabled_and_mapped_to_host

- name: Checking that host libvirt is not running
  vars:
    service: "{{ nova_cell_services['nova-libvirt'] }}"
  stat: path=/var/run/libvirt/libvirt-sock
  register: result
  failed_when: result.stat.exists
  when:
    - container_facts.containers['nova_libvirt'] is not defined
    - service | service_enabled_and_mapped_to_host

- name: Checking that nova_libvirt container is not running
  vars:
    nova_libvirt: "{{ nova_cell_services['nova-libvirt'] }}"
  fail:
    msg: >-
      The nova_libvirt container is running, however it has been disabled via
      the 'enable_nova_libvirt_container' flag. Stop and remove the container
      manually, taking care to migrate any state to the host libvirt daemon.
  when:
    - container_facts.containers['nova_libvirt'] is defined
    - not nova_libvirt.enabled | bool
    - inventory_hostname in groups[nova_libvirt.group]