Refactor vif plugging validations

It makes no sense to lump vif_plugging_timeout and vif_plugging_fatal
into the same tasks. One is a numeric value validated to be larger
than a minimum, the other is a boolean value validated to be set to
True. Split them into separate tasks, and clarify the failure error
messages.

Closes-Bug: #1901297
Related: rhbz#1891197

Change-Id: I7a28f6014c55293d018d5fbc3223a26a10550f1c
(cherry picked from commit ee19a57bc5)
This commit is contained in:
Artom Lifshitz 2020-08-21 14:40:00 -04:00 committed by Alexey Stupnikov
parent 766ac4c93d
commit bbc99b7aee
1 changed files with 20 additions and 13 deletions

View File

@ -1,24 +1,31 @@
---
- name: Get VIF Plugging setting values from nova.conf
- name: Get vif_plugging_fatal value from nova.conf
become: true
validations_read_ini:
path: "{{ nova_config_file }}"
section: DEFAULT
key: "{{ item }}"
key: "{{ vif_plugging_fatal_check }}"
ignore_missing_file: true
register: nova_config_result
with_items:
- "{{ vif_plugging_fatal_check }}"
- "{{ vif_plugging_timeout_check }}"
register: vif_plugging_fatal_value
- name: Check Nova configuration values
- name: Get vif_plugging_timeout value from nova.conf
become: true
validations_read_ini:
path: "{{ nova_config_file }}"
section: DEFAULT
key: "{{ vif_plugging_timeout_check }}"
ignore_missing_file: true
register: vif_plugging_timeout_value
- name: Ensure vif plugging timeout minimum
fail:
msg: "Value of {{ item.item }} is set to {{ item.value or 'None' }}."
when:
- "(item.item == vif_plugging_fatal_check and (not item.value|bool or None)) or
(item.item == vif_plugging_timeout_check and (item.value|int <= vif_plugging_timeout_value_min|int
or None))"
with_items: "{{ nova_config_result.results }}"
msg: "vif_plugging_timeout is below minimum value. Minimum: {{ vif_plugging_timeout_value_min|int }}. Current value: {{ vig_plugging_timeout_value }}"
when: "{{ vif_plugging_timeout_value|int < vif_plugging_timeout_value_min|int }}"
- name: Ensure vif plugging is fatal
fail:
msg: "vif_plugging_fatal should be set to True. Current value: {{ vif_plugging_fatal_value }}."
when: "not {{ vif_plugging_fatal_value|bool }}"
- name: Get auth_url value from hiera
become: true