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

- name: Get container facts
  become: true
  kolla_container_facts:
    action: get_containers
    container_engine: "{{ kolla_container_engine }}"
    name:
      - ironic_api
      - ironic_http
      - ironic_prometheus_exporter
  check_mode: false
  register: container_facts

- name: Checking free port for Ironic API
  wait_for:
    host: "{{ api_interface_address }}"
    port: "{{ ironic_api_listen_port }}"
    connect_timeout: 1
    timeout: 1
    state: stopped
  when:
    - container_facts.containers['ironic_api'] is not defined
    - inventory_hostname in groups['ironic-api']

- name: Checking free port for Ironic HTTP server
  wait_for:
    host: "{{ api_interface_address }}"
    port: "{{ ironic_http_port }}"
    connect_timeout: 1
    timeout: 1
    state: stopped
  when:
    - container_facts.containers['ironic_http'] is not defined
    - inventory_hostname in groups['ironic-http']

- name: Checking free port for Ironic Prometheus Exporter
  wait_for:
    host: "{{ api_interface_address }}"
    port: "{{ ironic_prometheus_exporter_port }}"
    connect_timeout: 1
    timeout: 1
    state: stopped
  when:
    - enable_ironic_prometheus_exporter | bool
    - container_facts.containers['ironic_prometheus_exporter'] is not defined
    - inventory_hostname in groups['ironic-conductor']

- name: Checking ironic-agent files exist for Ironic
  stat:
    path: "{{ ironic_agent_files_directory }}/ironic/{{ item }}"
  delegate_to: localhost
  run_once: true
  register: result
  failed_when: not result.stat.exists
  when:
    # Only required when Ironic dnsmasq is in use.
    - groups['ironic-dnsmasq'] | length > 0
    - (not ironic_dnsmasq_serve_ipxe | bool and inventory_hostname in groups['ironic-tftp']) or
        (ironic_dnsmasq_serve_ipxe | bool and inventory_hostname in groups['ironic-http'])
  with_items:
    - "ironic-agent.kernel"
    - "ironic-agent.initramfs"

- name: Ensure ironic_dnsmasq_dhcp_ranges is configured
  fail:
    msg: >
      ironic_dnsmasq_dhcp_ranges must be a list
  connection: local
  run_once: True
  when:
    - enable_ironic_dnsmasq | bool
    - not ironic_dnsmasq_dhcp_ranges is sequence