Merge "[ovn] Deleting ovn agents during scale down tasks"

This commit is contained in:
Zuul 2021-11-12 04:18:10 +00:00 committed by Gerrit Code Review
commit 65c005cf9a

View File

@ -428,3 +428,47 @@ outputs:
ovn_bridge_mappings: {get_attr: [OVNBridgeMappingsValue, value, ovn_bridge_mappings]}
ovn_static_bridge_mac_mappings: {get_attr: [OVNBridgeMappingsValue, value, ovn_static_bridge_mac_mappings]}
upgrade_tasks: []
scale_tasks:
- when:
- step|int == 1
- container_cli == 'podman'
tags: down
environment:
OS_CLOUD: {get_param: RootStackName}
block:
# Some tasks are running from the Undercloud which has
# the OpenStack clients installed.
- name: Get neutron agents ID
command: openstack network agent list --column ID --column Host --column Binary --format yaml
register: neutron_agents_result
delegate_to: "{{ groups['Undercloud'] | first }}"
check_mode: false
changed_when: false
- name: Filter only current host
set_fact:
neutron_agents: "{{ neutron_agents_result.stdout | from_yaml | selectattr('Host', 'match', ansible_facts['fqdn'] ~ '.*') | list }}"
delegate_to: "{{ groups['Undercloud'] | first }}"
check_mode: false
- name: Deleting OVN agents
block:
- name: Stop OVN containers
loop:
- tripleo_ovn_controller
- tripleo_ovn_metadata_agent
service:
name: "{{ item }}"
state: stopped
enabled: false
become: true
register: stop_containers
failed_when: "('msg' in stop_containers and
'Could not find the requested service' not in stop_containers.msg) or
('rc' in stop_containers and stop_containers.rc != 0)"
- name: Delete neutron agents
loop: "{{ neutron_agents }}"
loop_control:
loop_var: agent
label: "{{ agent.Host }}/{{ agent.Binary }}"
command: openstack network agent delete {{ agent.ID }}
delegate_to: "{{ groups['Undercloud'] | first }}"
check_mode: false