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