diff --git a/lib/ansible/module_utils/network/ios/ios.py b/lib/ansible/module_utils/network/ios/ios.py index 1b091e75b0e..f1671ecd08f 100644 --- a/lib/ansible/module_utils/network/ios/ios.py +++ b/lib/ansible/module_utils/network/ios/ios.py @@ -166,7 +166,8 @@ def load_config(module, commands): connection = get_connection(module) try: - diff, response = connection.edit_config(commands) - return response + resp = connection.edit_config(commands) + resp = json.loads(resp) + return resp.get('response') except ConnectionError as exc: module.fail_json(msg=to_text(exc)) diff --git a/lib/ansible/module_utils/network/vyos/vyos.py b/lib/ansible/module_utils/network/vyos/vyos.py index 0d9dc41d4ee..2295a41242c 100644 --- a/lib/ansible/module_utils/network/vyos/vyos.py +++ b/lib/ansible/module_utils/network/vyos/vyos.py @@ -133,7 +133,9 @@ def load_config(module, commands, commit=False, comment=None): connection = get_connection(module) try: - diff_config, resp = connection.edit_config(candidate=commands, commit=commit, diff=module._diff, comment=comment) + resp = connection.edit_config(candidate=commands, commit=commit, diff=module._diff, comment=comment) + resp = json.loads(resp) + diff_config = resp.get('diff') except ConnectionError as exc: module.fail_json(msg=to_text(exc)) diff --git a/lib/ansible/plugins/cliconf/__init__.py b/lib/ansible/plugins/cliconf/__init__.py index 39df307046d..4708fff1823 100644 --- a/lib/ansible/plugins/cliconf/__init__.py +++ b/lib/ansible/plugins/cliconf/__init__.py @@ -206,9 +206,13 @@ class CliconfBase(with_metaclass(ABCMeta, object)): :param diff: Boolean flag to indicate if configuration that is applied on remote host should generated and returned in response or not :param comment: Commit comment provided it is supported by remote host - :return: Returns a tuple, the first entry of tupe is configuration diff if diff flag is enable else - it is None. Second entry is the list of response received from remote host on executing - configuration commands. + :return: Returns a json string with contains configuration applied on remote host, the returned + response on executing configuration commands and platform relevant data. + { + "diff": "", + "response": [] + } + """ pass diff --git a/lib/ansible/plugins/cliconf/ios.py b/lib/ansible/plugins/cliconf/ios.py index b2e50229475..ac9bb4cd0b7 100644 --- a/lib/ansible/plugins/cliconf/ios.py +++ b/lib/ansible/plugins/cliconf/ios.py @@ -125,6 +125,7 @@ class Cliconf(CliconfBase): @enable_mode def edit_config(self, candidate=None, commit=True, replace=False, diff=False, comment=None): + resp = {} if not candidate: raise ValueError("must provide a candidate config to load") @@ -154,7 +155,9 @@ class Cliconf(CliconfBase): if diff: diff_config = candidate - return diff_config, results[1:-1] + resp['diff'] = diff_config + resp['response'] = results[1:-1] + return json.dumps(resp) def get(self, command=None, prompt=None, answer=None, sendonly=False): if not command: diff --git a/lib/ansible/plugins/cliconf/vyos.py b/lib/ansible/plugins/cliconf/vyos.py index f2dd1270f48..430a2c17334 100644 --- a/lib/ansible/plugins/cliconf/vyos.py +++ b/lib/ansible/plugins/cliconf/vyos.py @@ -61,6 +61,7 @@ class Cliconf(CliconfBase): return out def edit_config(self, candidate=None, commit=True, replace=False, diff=False, comment=None): + resp = {} if not candidate: raise ValueError('must provide a candidate config to load') @@ -98,7 +99,9 @@ class Cliconf(CliconfBase): else: self.discard_changes() - return diff_config, results[1:] + resp['diff'] = diff_config + resp['response'] = results[1:] + return json.dumps(resp) def get(self, command=None, prompt=None, answer=None, sendonly=False): if not command: