mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-08 06:12:51 +00:00
Check for ConnectionError on change of config or commands (#41504)
This commit is contained in:
@@ -146,11 +146,11 @@ def run_commands(module, commands, check_rc=True):
|
||||
|
||||
try:
|
||||
out = connection.get(command, prompt, answer)
|
||||
except ConnectionError as e:
|
||||
except ConnectionError as exc:
|
||||
if check_rc:
|
||||
raise
|
||||
module.fail_json(msg=to_text(exc))
|
||||
else:
|
||||
out = e
|
||||
out = exc
|
||||
|
||||
try:
|
||||
out = to_text(out, errors='surrogate_or_strict')
|
||||
@@ -165,4 +165,7 @@ def run_commands(module, commands, check_rc=True):
|
||||
def load_config(module, commands):
|
||||
connection = get_connection(module)
|
||||
|
||||
return connection.edit_config(commands)
|
||||
try:
|
||||
return connection.edit_config(commands)
|
||||
except ConnectionError as exc:
|
||||
module.fail_json(msg=to_text(exc))
|
||||
|
||||
Reference in New Issue
Block a user