Execution
Date 08 Dec 2025 13:57:07 +0000
Duration 00:24:46.17
Controller aio1.openstack.local
User root
Versions
Ansible 2.18.6
ara 1.7.4 / 1.7.4
Python 3.12.11
Summary
12 Hosts
1505 Tasks
1497 Results
32 Plays
487 Files
0 Records

File: /home/zuul/src/opendev.org/openstack/openstack-ansible-os_nova/tasks/nova_db_post_setup.yml

---
# Copyright 2017, Rackspace US, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

- name: Set the delegated task facts
  ansible.builtin.set_fact:
    _db_nova_bin: "{{ hostvars[nova_conductor_setup_host]['nova_bin'] | default(nova_bin) }}"
    _db_nova_system_user_name: "{{ hostvars[nova_conductor_setup_host]['nova_system_user_name'] | default(nova_system_user_name) }}"

# This needs to be done after Compute hosts are added.
- name: Perform a cell_v2 discover
  ansible.builtin.command: >-
    {{ _db_nova_bin }}/nova-manage --config-file {{ nova_conf_version_dir }}/nova.conf cell_v2 discover_hosts{{ (debug | bool) | ternary(' --verbose', '') }}{{
      (nova_ironic_used | bool) | ternary(' --by-service', '') }}
  become: true
  become_user: "{{ _db_nova_system_user_name }}"
  changed_when: false

# If it exits with partial updates (exit status 1) it should be called again,
# even if some updates initially generated errors,
# because some updates may depend on others having completed. If it exits with status 2,
# intervention is required to resolve the issue causing remaining updates to fail.
# It should be considered successfully completed only when the exit status is 0.
- name: Perform online data migrations
  ansible.builtin.command: "{{ _db_nova_bin }}/nova-manage --config-file {{ nova_conf_version_dir }}/nova.conf db online_data_migrations"
  become: true
  become_user: "{{ _db_nova_system_user_name }}"
  changed_when: false
  when:
    - hostvars[nova_conductor_setup_host]['ansible_local']['openstack_ansible']['nova']['need_online_data_migrations'] | bool
  retries: 5
  delay: 3
  until: "data_migrations.rc in [0, 2]"
  register: data_migrations

- name: Disable the online migrations requirement
  delegate_to: "{{ item }}"
  community.general.ini_file:
    dest: "/etc/ansible/facts.d/openstack_ansible.fact"
    section: nova
    option: need_online_data_migrations
    value: false
    mode: "0644"
  with_items: "{{ groups[nova_services['nova-conductor']['group']] }}"
  when:
    - data_migrations is not skipped
    - data_migrations is succeeded

- name: Create service and timer for archiving deleted records
  ansible.builtin.include_role:
    name: systemd_service
  vars:
    systemd_service_restart_changed: false
    systemd_user_name: "{{ nova_system_user_name }}"
    systemd_group_name: "{{ nova_system_group_name }}"
    systemd_tempd_prefix: openstack
    systemd_slice_name: "{{ nova_system_slice_name }}"
    systemd_lock_dir: "{{ nova_lock_dir }}"
    systemd_services:
      - service_name: "nova-archive-deleted"
        execstarts:
          - /bin/sh -c "{{ _db_nova_bin }}/nova-manage db archive_deleted_rows --until-complete --all-cells --before \"$(date -d '{{ nova_archive_deleted_before }}' +'%%Y-%%m-%%d %%H:%%M')\" {{ (nova_archive_deleted_purge) | ternary('--purge', '') }} {{ (nova_archive_task_log) | ternary('--task-log', '') }}" # noqa: yaml[line-length]
        environment:
          UMASK: "0640"
          UMASK_DIR: "0750"
        program_sandboxing:
          RuntimeDirectory: "nova-archive-deleted"
        enabled: "{{ nova_archive_deleted }}"
        timer:
          state: "{{ nova_archive_deleted | ternary('started', 'stopped') }}"
          enabled: "{{ nova_archive_deleted }}"
          options:
            OnCalendar: "{{ nova_archive_deleted_on_calendar }}"
            RandomizedDelaySec: "{{ nova_archive_deleted_randomized_delay_sec }}"
            Persistent: true
            Unit: "nova-archive-deleted.service"
      - service_name: "nova-purge-deleted"
        execstarts:
          - /bin/sh -c "{{ _db_nova_bin }}/nova-manage db purge --all-cells --before \"$(date -d '{{ nova_purge_deleted_before }}' +'%%Y-%%m-%%d %%H:%%M')\"" # noqa: yaml[line-length]
        environment:
          UMASK: "0640"
          UMASK_DIR: "0750"
        program_sandboxing:
          RuntimeDirectory: "nova-purge-deleted"
        enabled: "{{ nova_purge_deleted }}"
        timer:
          state: "{{ nova_purge_deleted | ternary('started', 'stopped') }}"
          enabled: "{{ nova_purge_deleted }}"
          options:
            OnCalendar: "{{ nova_purge_deleted_on_calendar }}"
            RandomizedDelaySec: "{{ nova_purge_deleted_randomized_delay_sec }}"
            Persistent: true
            Unit: "nova-purge-deleted.service"