aboutsummaryrefslogtreecommitdiff
path: root/ansible/roles/ironic/tasks/upgrade.yml
blob: 2e7b4d6b8e6996da62ed4718f9abd26c4262923d (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
---
# TODO(mnasiadka): Remove this task in Gazpacho/2026.1 release
- name: Remove ironic-inspector
  become: true
  kolla_container:
    action: "stop_and_remove_container"
    common_options: "{{ docker_common_options }}"
    name: "ironic_inspector"
    ignore_missing: true

# TODO(mnasiadka): Remove this block in Gazpacho/2026.1 release
- name: Handle volume migration for ironic_dnsmasq
  when: enable_ironic_dnsmasq | bool
  block:
    - name: Stop ironic_dnsmasq container
      become: true
      kolla_container:
        action: "stop_container"
        common_options: "{{ docker_common_options }}"
        name: "ironic_dnsmasq"
        ignore_missing: true

    - name: Create ironic_dhcp_hosts volume
      become: true
      changed_when: true
      command: "{{ kolla_container_engine }} volume create ironic_dhcp_hosts"

    - name: Migrate data from ironic_inspector_dhcp_hosts volume
      become: true
      changed_when: true
      vars:
        volumes_dir: >-
          {{ '/var/lib/docker/volumes' if kolla_container_engine == 'docker'
          else '/var/lib/containers/storage/volumes' }}
      command: >-
        mv {{ volumes_dir }}/ironic_inspector_dhcp_hosts/_data/
        {{ volumes_dir }}/ironic_dhcp_hosts/_data

- name: Get Ironic API container facts
  become: true
  vars:
    container_name: "{{ ironic_services['ironic-api'].container_name }}"
  kolla_container_facts:
    action: get_containers
    container_engine: "{{ kolla_container_engine }}"
    name:
      - "{{ container_name }}"
  check_mode: false
  register: container_facts

- name: Wait for Ironic nodes not to wait
  become: true
  vars:
    container_name: "{{ ironic_services['ironic-api'].container_name }}"
  command: >
    {{ kolla_container_engine }} exec kolla_toolbox openstack
    --os-interface {{ openstack_interface }}
    --os-auth-url {{ openstack_auth.auth_url }}
    --os-username {{ openstack_auth.username }}
    --os-password {{ openstack_auth.password }}
    --os-identity-api-version 3
    --os-user-domain-name {{ openstack_auth.user_domain_name }}
    --os-system-scope "all"
    --os-region-name {{ openstack_region_name }}
    {% if openstack_cacert != '' %}--os-cacert {{ openstack_cacert }}{% endif %}
    baremetal node list --format json --column "Provisioning State"
  register: ironic_nodes
  changed_when: false
  retries: 10
  delay: 30
  until:
    - ironic_nodes is success
    - (ironic_nodes.stdout |
       from_json |
       map(attribute='Provisioning State') |
       select('search', '\\bwait\\b') |
       length) == 0
  run_once: true
  when:
    - not ironic_upgrade_skip_wait_check | bool
    - container_facts.containers[container_name] is defined

- include_tasks: rolling_upgrade.yml
  when: ironic_enable_rolling_upgrade | bool

- include_tasks: legacy_upgrade.yml
  when: not ironic_enable_rolling_upgrade | bool

# TODO(mnasiadka): Remove this task in Gazpacho/2026.1 release
- name: Remove ironic_inspector_dhcp_hosts volume
  become: true
  changed_when: true
  command: "{{ kolla_container_engine }} volume rm ironic_inspector_dhcp_hosts"
  when: enable_ironic_dnsmasq | bool