Check for ConnectionError on change of config or commands (#41504)

This commit is contained in:
Nathaniel Case 2018-06-14 09:45:54 -04:00 committed by GitHub
parent 5814b90835
commit 50e776877d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 45 additions and 14 deletions

View file

@ -114,7 +114,10 @@ def run_commands(module, commands, check_rc=True):
prompt = None
answer = None
out = connection.get(command, prompt, answer)
try:
out = connection.get(command, prompt, answer)
except ConnectionError as exc:
module.fail_json(msg=to_text(exc))
try:
out = to_text(out, errors='surrogate_or_strict')
@ -129,7 +132,10 @@ def run_commands(module, commands, check_rc=True):
def load_config(module, commands, commit=False, comment=None):
connection = get_connection(module)
out = connection.edit_config(commands)
try:
out = connection.edit_config(commands)
except ConnectionError as exc:
module.fail_json(msg=to_text(exc))
diff = None
if module._diff: