mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Sanitize the output from ovs get-fail-mode (#24208)
If a bridge does not have a fail mode set, it returns nothing, i.e. empty string. This causes a failure when doing the want vs have compare in plays where the fail-mode is missing, as we compare "" vs None respectively.
This commit is contained in:
parent
e67eba877e
commit
9e246a857c
1 changed files with 7 additions and 1 deletions
|
@ -116,6 +116,12 @@ from ansible.module_utils.basic import AnsibleModule
|
|||
from ansible.module_utils.six import iteritems
|
||||
from ansible.module_utils.pycompat24 import get_exception
|
||||
|
||||
def _fail_mode_to_str(text):
|
||||
if not text:
|
||||
return None
|
||||
else:
|
||||
return text.strip()
|
||||
|
||||
def _external_ids_to_dict(text):
|
||||
if not text:
|
||||
return None
|
||||
|
@ -216,7 +222,7 @@ def map_config_to_obj(module):
|
|||
" %(bridge)s")
|
||||
command = templatized_command % module.params
|
||||
rc, out, err = module.run_command(command, check_rc=True)
|
||||
obj['fail_mode'] = out.strip()
|
||||
obj['fail_mode'] = _fail_mode_to_str(out)
|
||||
|
||||
templatized_command = ("%(ovs-vsctl)s -t %(timeout)s br-get-external-id"
|
||||
" %(bridge)s")
|
||||
|
|
Loading…
Reference in a new issue