From 9e246a857c66022f7f167d77f06cf7b502ac5378 Mon Sep 17 00:00:00 2001 From: Ricardo Carrillo Cruz Date: Tue, 2 May 2017 17:04:33 +0200 Subject: [PATCH] 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. --- lib/ansible/modules/network/ovs/openvswitch_bridge.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/ansible/modules/network/ovs/openvswitch_bridge.py b/lib/ansible/modules/network/ovs/openvswitch_bridge.py index 11ec5305cbc..85595e78811 100644 --- a/lib/ansible/modules/network/ovs/openvswitch_bridge.py +++ b/lib/ansible/modules/network/ovs/openvswitch_bridge.py @@ -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")