From ef4ca0c2b452156794f2667d431f387f2cefb4bc Mon Sep 17 00:00:00 2001 From: Dmitriy Rabotyagov Date: Wed, 12 Apr 2023 11:32:16 +0200 Subject: [PATCH] Delegate compute wait tasks to service_setup_host At the moment, we do deploy openrc file on conductors and delegate task to them. At the moment there is no good reason to do so, since we're actively utilizing service_setup_host for all interactions with API. With that we also replace `openstack` commands with native compute_service_info module that provides all information we need. Change-Id: I016ba4c5dd211c5165a74a6011da7bb384c7a82a --- tasks/main.yml | 4 ---- tasks/nova_compute_wait.yml | 33 ++++++++++++++++++--------------- 2 files changed, 18 insertions(+), 19 deletions(-) diff --git a/tasks/main.yml b/tasks/main.yml index 454b1ea2..eea5a8e6 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -276,11 +276,7 @@ - name: Flush handlers meta: flush_handlers -# We delegate this back to the conductor because that is -# where we want to isolate the clouds.yaml configuration, -# rather than have it implemented on all compute nodes. - import_tasks: nova_compute_wait.yml - delegate_to: "{{ nova_conductor_setup_host }}" when: - "nova_services['nova-compute']['group'] in group_names" - "nova_discover_hosts_in_cells_interval | int < 1" diff --git a/tasks/nova_compute_wait.yml b/tasks/nova_compute_wait.yml index 751191bd..33f308a0 100644 --- a/tasks/nova_compute_wait.yml +++ b/tasks/nova_compute_wait.yml @@ -13,34 +13,37 @@ # See the License for the specific language governing permissions and # limitations under the License. -- name: Implement openrc/clouds.yaml - include_role: - name: "openstack_openrc" - -- name: Set the delegated task facts - set_fact: - _wait_nova_bin: "{{ hostvars[nova_conductor_setup_host]['nova_bin'] | default(nova_bin) }}" - -- block: +- name: Ensure compute is discovered + block: - name: Wait for the nova-compute service to initialize - command: "{{ _wait_nova_bin }}/openstack --os-cloud default compute service list --service nova-compute --format value --column Host" - changed_when: false + delegate_to: "{{ nova_service_setup_host }}" + vars: + ansible_python_interpreter: "{{ nova_service_setup_host_python_interpreter }}" + openstack.cloud.compute_service_info: + cloud: default + binary: "nova-compute" + host: "{{ compute_host_to_wait_for }}" register: _compute_host_list retries: 10 delay: 5 - until: "compute_host_to_wait_for in _compute_host_list.stdout_lines" + until: "_compute_host_list.compute_services" rescue: - name: Restart nova-compute service service: name: "{{ nova_services['nova-compute']['service_name'] }}" state: restarted - delegate_to: "{{ compute_host_to_wait_for }}" - name: Wait for the nova-compute service to initialize - command: "{{ _wait_nova_bin }}/openstack --os-cloud default compute service list --service nova-compute --format value --column Host" + delegate_to: "{{ nova_service_setup_host }}" + vars: + ansible_python_interpreter: "{{ nova_service_setup_host_python_interpreter }}" + openstack.cloud.compute_service_info: + cloud: default + binary: "nova-compute" + host: "{{ compute_host_to_wait_for }}" changed_when: false register: _compute_host_list retries: 10 delay: 5 - until: "compute_host_to_wait_for in _compute_host_list.stdout_lines" + until: "_compute_host_list.compute_services"