neutron: Use assert on checks for readability

assert will also fail when we're not meeting the conditions, makes
clear what we're actually testing, and isn't listed as a skipped task
when the condition is ok.

Change-Id: I3e396f1c605d5d2644e757bbb3d954efe537b65e
This commit is contained in:
Erik Berg 2023-01-09 18:59:42 +01:00
parent 2b88144c05
commit 391f49c949
No known key found for this signature in database
GPG Key ID: 1182D19B0E5ED030

View File

@ -25,31 +25,30 @@
- inventory_hostname in groups['neutron-server'] - inventory_hostname in groups['neutron-server']
- name: Checking number of network agents - name: Checking number of network agents
fail: assert:
msg: "Number of network agents are less than two when enabling agent ha" that:
- groups['neutron-dhcp-agent'] | length > 1
- groups['neutron-l3-agent'] | length > 1
fail_msg: "Number of network agents are less than two when enabling agent ha"
changed_when: false changed_when: false
run_once: True run_once: True
when: when:
- enable_neutron_agent_ha | bool - enable_neutron_agent_ha | bool
- groups['neutron-dhcp-agent'] | length < 2
or groups['neutron-l3-agent'] | length < 2
- name: Checking tenant network types - name: Checking tenant network types
assert:
that: item in type_drivers
fail_msg: "Tenant network type '{{ item }}' is not in type drivers [{{ neutron_type_drivers }}]"
with_items: "{{ tenant_network_types }}"
vars: vars:
type_drivers: "{{ neutron_type_drivers.replace(' ', '').split(',') | reject('equalto', '') | list }}" type_drivers: "{{ neutron_type_drivers.replace(' ', '').split(',') | reject('equalto', '') | list }}"
tenant_network_types: "{{ neutron_tenant_network_types.replace(' ', '').split(',') | reject('equalto', '') | list }}" tenant_network_types: "{{ neutron_tenant_network_types.replace(' ', '').split(',') | reject('equalto', '') | list }}"
fail:
msg: "Tenant network type '{{ item }}' is not in type drivers [{{ neutron_type_drivers }}]"
changed_when: false
when: item not in type_drivers
run_once: true run_once: true
with_items: "{{ tenant_network_types }}"
- name: Checking whether Ironic enabled - name: Checking whether Ironic enabled
fail: assert:
msg: "Ironic must be enabled when using networking-baremetal/ironic-neutron-agent" that: enable_ironic | bool
changed_when: false fail_msg: "Ironic must be enabled when using networking-baremetal/ironic-neutron-agent"
run_once: True run_once: True
when: when:
- enable_ironic_neutron_agent | bool - enable_ironic_neutron_agent | bool
- not (enable_ironic | bool)