{"id":878,"sha1":"6b11dba594dea9320ee35fa5f3498c54758adbe2","playbook":{"id":4,"items":{"plays":107,"tasks":2438,"results":2413,"hosts":13,"files":511,"records":0},"arguments":{"version":null,"verbosity":0,"private_key_file":null,"remote_user":null,"connection":"openstack.osa.ssh","timeout":null,"ssh_common_args":null,"sftp_extra_args":null,"scp_extra_args":null,"ssh_extra_args":null,"ask_pass":false,"connection_password_file":null,"force_handlers":true,"flush_cache":false,"become":false,"become_method":"sudo","become_user":null,"become_ask_pass":false,"become_password_file":null,"tags":["all"],"skip_tags":[],"check":false,"diff":false,"inventory":["/home/zuul/src/opendev.org/openstack/openstack-ansible/inventory/dynamic_inventory.py","/home/zuul/src/opendev.org/openstack/openstack-ansible/inventory/inventory.ini","/etc/openstack_deploy/inventory.ini"],"listhosts":false,"subset":null,"extra_vars":"Not saved by ARA as configured by 'ignored_arguments'","vault_ids":[],"ask_vault_pass":false,"vault_password_files":[],"forks":4,"module_path":null,"syntax":false,"listtasks":false,"listtags":false,"step":false,"start_at_task":null,"args":["setup-openstack.yml"]},"labels":[{"id":1,"name":"check:False"},{"id":2,"name":"tags:all"}],"started":"2025-12-14T10:21:40.790759Z","ended":"2025-12-14T11:05:36.775743Z","duration":"00:43:55.984984","name":null,"ansible_version":"2.18.6","client_version":"1.7.4","python_version":"3.13.5","server_version":"1.7.4","status":"completed","path":"/home/zuul/src/opendev.org/openstack/openstack-ansible/playbooks/setup-openstack.yml","controller":"aio1.openstack.local","user":"root"},"content":"---\n# Copyright 2014, Rackspace US, Inc.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#     http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\n- name: Synchronize the nova API DB schema\n  ansible.builtin.command: \"{{ nova_bin }}/nova-manage --config-file {{ nova_conf_version_dir }}/nova.conf api_db sync\"\n  become: true\n  become_user: \"{{ nova_system_user_name }}\"\n  changed_when: false\n\n# We need to check for existance of the cell, since nova-manage cell_v2 create_cell\n# might be not idempotent due to the bug https://bugs.launchpad.net/nova/+bug/1923899\n- name: Get UUID of Nova Cells\n  ansible.builtin.command: \"{{ nova_bin }}/nova-manage --config-file {{ nova_conf_version_dir }}/nova.conf cell_v2 list_cells\"\n  become: true\n  become_user: \"{{ nova_system_user_name }}\"\n  changed_when: false\n  register: _cell_list\n\n- name: Set cell facts\n  ansible.builtin.set_fact:\n    _cell0_record: '{{ _cell_list.stdout_lines | select(\"regex\", \"[0-]{36}\") }}'\n    _cell1_record: '{{ _cell_list.stdout_lines | select(\"regex\", \" \" ~ nova_cell1_name ~ \" \") }}'\n\n# This is idempotent and therefore safe for greenfield\n# and brownfield installations.\n# Though since we anyway need to fetch cell records - let's run\n# it conditionally.\n- name: Create the cell0 mapping entry in the nova API DB\n  ansible.builtin.command: >-\n    {{ nova_bin }}/nova-manage --config-file {{ nova_conf_version_dir }}/nova.conf cell_v2 map_cell0\n      --database_connection mysql+pymysql://{{ nova_api_galera_user }}:{{ nova_api_container_mysql_password }}@{{ nova_api_galera_address }}/{{\n        nova_cell0_database }}?charset=utf8{% if nova_galera_use_ssl | bool %}&ssl_verify_cert=true{%\n          if nova_galera_ssl_ca_cert | length > 0 %}&ssl_ca={{ nova_galera_ssl_ca_cert }}{% endif %}{% endif %}\n  become: true\n  become_user: \"{{ nova_system_user_name }}\"\n  changed_when: false\n  when:\n    - not _cell0_record\n\n- name: Update the cell0 mapping entry in the nova API DB\n  ansible.builtin.command: >-\n    {{ nova_bin }}/nova-manage --config-file {{ nova_conf_version_dir }}/nova.conf cell_v2 update_cell --cell_uuid 00000000-0000-0000-0000-000000000000\n      --database_connection mysql+pymysql://{{ nova_api_galera_user }}:{{ nova_api_container_mysql_password }}@{{ nova_api_galera_address }}/{{\n        nova_cell0_database }}?charset=utf8{% if nova_galera_use_ssl | bool %}&ssl_verify_cert=true{%\n          if nova_galera_ssl_ca_cert | length > 0 %}&ssl_ca={{ nova_galera_ssl_ca_cert }}{% endif %}{% endif %}\n      --transport-url 'none:/'\n  become: true\n  become_user: \"{{ nova_system_user_name }}\"\n  changed_when: false\n  when:\n    - _cell0_record | length > 0\n    - nova_cell_force_update or\n      ('ssl_verify_cert' not in _cell0_record[0] and nova_galera_use_ssl) or\n      ('ssl_verify_cert' in _cell0_record[0] and not nova_galera_use_ssl)\n\n- name: Synchronize the nova DB schema\n  ansible.builtin.command: \"{{ nova_bin }}/nova-manage --config-file {{ nova_conf_version_dir }}/nova.conf db sync\"\n  become: true\n  become_user: \"{{ nova_system_user_name }}\"\n  changed_when: false\n\n- name: Create the cell1 mapping entry in the nova API DB\n  ansible.builtin.command: >-\n    {{ nova_bin }}/nova-manage --config-file {{ nova_conf_version_dir }}/nova.conf cell_v2 create_cell\n      --name {{ nova_cell1_name }}\n      --database_connection {scheme}://{username}:{password}@{hostname}:{port}/{path}?{query}\n      --transport-url {scheme}://{username}:{password}@{hostname}:{port}/{{ (\n          not nova_oslomsg_rabbit_quorum_queues | bool) | ternary('/{path}', '{path}') }}?{query}\n  become: true\n  become_user: \"{{ nova_system_user_name }}\"\n  register: nova_cell1_create\n  # When upgrading, cell1 will already exist and nova-manage will\n  # give a return code of 2, so we therefore know that if the\n  # return code is:\n  # 0: the cell mapping record in the nova API database was\n  #    successfully implemented (greenfield install)\n  # 2: the cell mapping record in the nova API database already\n  #    exists (brownfield install). This is not working for templates\n  #    because of the bug https://bugs.launchpad.net/nova/+bug/1923899\n  failed_when: \"nova_cell1_create.rc not in [0, 2]\"\n  changed_when: \"nova_cell1_create.rc == 0\"\n  when:\n    - not _cell1_record\n\n- name: \"Change the template for cell {{ nova_cell1_name }}\"\n  ansible.builtin.command: >-\n    {{ nova_bin }}/nova-manage --config-file {{ nova_conf_version_dir }}/nova.conf cell_v2 update_cell\n      --cell_uuid {{ _cell1_record[0].split()[3] }}\n      --database_connection {scheme}://{username}:{password}@{hostname}:{port}/{path}?{query}\n      --transport-url {scheme}://{username}:{password}@{hostname}:{port}/{{ (\n          not nova_oslomsg_rabbit_quorum_queues | bool) | ternary('/{path}', '{path}') }}?{query}\n  become: true\n  become_user: \"{{ nova_system_user_name }}\"\n  changed_when: false\n  when:\n    - _cell1_record | length > 0\n    - nova_cell_force_update or\n      (nova_oslomsg_rpc_port ~ '/' ~ _nova_oslomsg_rpc_vhost_conf) not in _cell1_record[0]\n\n# The nova-status upgrade check command is typically run after upgrading the\n# controller services to new code, but is also OK to run for a greenfield\n# install to verify everything is setup correctly. This must run after cell\n# mapping setup and before actual service restart.\n# https://docs.openstack.org/nova/latest/cli/nova-status.html\n- name: Run nova-status upgrade check to validate a healthy configuration\n  ansible.builtin.command: \"{{ nova_bin }}/nova-status --config-file {{ nova_conf_version_dir }}/nova.conf upgrade check\"\n  become: true\n  become_user: \"{{ nova_system_user_name }}\"\n  register: nova_status_upgrade_check\n  until: nova_status_upgrade_check is success\n  retries: 8\n  delay: 15\n  # The nova-status upgrade check command has three standard return codes:\n  # 0: all checks were successful\n  # 1: warning: there might be some checks that require investigation, but\n  #    generally will not block an automated install/upgrade; digging into\n  #    warnings is useful for debugging post-install/upgrade issues\n  # 2: at least one check failed and must stop the install/upgrade because\n  #    something was not setup properly\n  failed_when: \"nova_status_upgrade_check.rc not in [0, 1]\"\n  changed_when: false\n  when:\n    - \"ansible_local['openstack_ansible']['nova']['need_online_data_migrations'] | bool\"\n","created":"2025-12-14T10:41:04.124729Z","updated":"2025-12-14T10:41:04.124740Z","path":"/home/zuul/src/opendev.org/openstack/openstack-ansible-os_nova/tasks/nova_db_setup.yml"}