From 707398789403293aaedc1d78ddc4a164611366c7 Mon Sep 17 00:00:00 2001 From: Jimmy McCrory Date: Thu, 22 Feb 2018 08:55:06 -0800 Subject: [PATCH] Rearrange cell mapping tasks Existing instances can be mapped to a newly created cell immediately after the cell is created and by the same conductor host that created the cell. After a new compute host is built, it will need to mapped to a cell through the 'discover_hosts' command of nova-manage. This command will still need to be run against a host that has direct database access, but the command is able to handle mapping of all compute hosts that do not currently belong to the cell so it only needs to be run once per play. There can be a short delay in the time between a compute service starting and becoming available to be discovered and mapped but, for most deployments, compute host discovery will be handled automatically as a periodic task. Conflicts: >------tasks/main.yml Change-Id: I4f7328e1aff79eb94f278999b97fbad8f44c6a3e Closes-Bug: 1749037 Related-Bug: 1729661 Related-Bug: 1752540 (cherry picked from commit 6321cf90304023c20dc6abb87e2fa20107b7051d) --- tasks/main.yml | 13 +++++-------- tasks/nova_db_post_setup.yml | 20 ++------------------ tasks/nova_db_setup.yml | 15 +++++++++++++++ 3 files changed, 22 insertions(+), 26 deletions(-) diff --git a/tasks/main.yml b/tasks/main.yml index 3b282c13..04e9f0e7 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -133,15 +133,12 @@ # because the compute hosts do not have access to # the database connection string and therefore # cannot run nova-manage. -# Also, we delegate this to a random host in the -# conductor group in order to spread the load of -# multiple forks across the group members. - include: nova_db_post_setup.yml - delegate_to: "{{ conductor_host }}" - with_random_choice: "{{ groups['nova_conductor'] }}" - loop_control: - loop_var: conductor_host + delegate_to: "{{ random_conductor }}" + run_once: true when: - - "'nova_compute' in group_names" + - "nova_services['nova-compute']['group'] in group_names" + vars: + random_conductor: "{{ groups[nova_services['nova-conductor']['group']] | random }}" tags: - nova-config diff --git a/tasks/nova_db_post_setup.yml b/tasks/nova_db_post_setup.yml index d6d4289c..758b4a4c 100644 --- a/tasks/nova_db_post_setup.yml +++ b/tasks/nova_db_post_setup.yml @@ -15,9 +15,8 @@ - name: Set the delegated task facts set_fact: - _db_nova_bin: "{{ hostvars[conductor_host]['nova_bin'] | default(nova_bin) }}" - _db_nova_system_user_name: "{{ hostvars[conductor_host]['nova_system_user_name'] | default(nova_system_user_name) }}" - _db_nova_cell1_name: "{{ hostvars[conductor_host]['nova_cell1_name'] | default(nova_cell1_name) }}" + _db_nova_bin: "{{ hostvars[random_conductor]['nova_bin'] | default(nova_bin) }}" + _db_nova_system_user_name: "{{ hostvars[random_conductor]['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 @@ -25,18 +24,3 @@ become: yes become_user: "{{ _db_nova_system_user_name }}" changed_when: false - -# When upgrading we need to map existing instances to the new cell1 -# To do this we need the cell UUID. -- name: Get UUID of new Nova Cell - shell: "{{ _db_nova_bin }}/nova-manage cell_v2 list_cells | grep ' {{ _db_nova_cell1_name }} '" - become: yes - become_user: "{{ _db_nova_system_user_name }}" - register: cell1_uuid - changed_when: false - -- name: Map instances to new Cell1 - command: "{{ _db_nova_bin }}/nova-manage cell_v2 map_instances --cell_uuid {{ cell1_uuid['stdout'].split()[3] }}" - become: yes - become_user: "{{ _db_nova_system_user_name }}" - changed_when: false diff --git a/tasks/nova_db_setup.yml b/tasks/nova_db_setup.yml index 5a342747..105345b9 100644 --- a/tasks/nova_db_setup.yml +++ b/tasks/nova_db_setup.yml @@ -73,3 +73,18 @@ when: - not data_migrations | skipped - data_migrations | succeeded + +# When upgrading we need to map existing instances to the new cell1 +# To do this we need the cell UUID. +- name: Get UUID of new Nova Cell + shell: "{{ nova_bin }}/nova-manage cell_v2 list_cells | grep ' {{ nova_cell1_name }} '" + become: yes + become_user: "{{ nova_system_user_name }}" + register: cell1_uuid + changed_when: false + +- name: Map instances to new Cell1 + command: "{{ nova_bin }}/nova-manage cell_v2 map_instances --cell_uuid {{ cell1_uuid['stdout'].split()[3] }}" + become: yes + become_user: "{{ nova_system_user_name }}" + changed_when: false