Vyos config fixes (#21862)
* Fix vyos signatures to match new versions * Fix test cases referring to 'updates' instead of 'commands' * I think this is an artifact of `connection: network_cli`?
This commit is contained in:
parent
ca21d09483
commit
9b9ed59d98
6 changed files with 5 additions and 29 deletions
|
@ -78,7 +78,7 @@ def load_config(module, commands, commit=False, comment=None):
|
||||||
module.fail_json(msg='unable to enter configuration mode', output=err)
|
module.fail_json(msg='unable to enter configuration mode', output=err)
|
||||||
|
|
||||||
for cmd in to_list(commands):
|
for cmd in to_list(commands):
|
||||||
rc, out, err = exec_command(module, cmd, check_rc=False)
|
rc, out, err = exec_command(module, cmd)
|
||||||
if rc != 0:
|
if rc != 0:
|
||||||
# discard any changes in case of failure
|
# discard any changes in case of failure
|
||||||
exec_command(module, 'exit discard')
|
exec_command(module, 'exit discard')
|
||||||
|
|
|
@ -221,10 +221,9 @@ def run(module, result):
|
||||||
|
|
||||||
commit = not module.check_mode
|
commit = not module.check_mode
|
||||||
comment = module.params['comment']
|
comment = module.params['comment']
|
||||||
save = module.params['save']
|
|
||||||
|
|
||||||
if commands:
|
if commands:
|
||||||
load_config(module, commands, commit=commit, comment=comment, save=save)
|
load_config(module, commands, commit=commit, comment=comment)
|
||||||
|
|
||||||
if result.get('filtered'):
|
if result.get('filtered'):
|
||||||
result['warnings'].append('Some configuration commands were '
|
result['warnings'].append('Some configuration commands were '
|
||||||
|
|
|
@ -40,7 +40,6 @@ except ImportError:
|
||||||
class ActionModule(_ActionModule):
|
class ActionModule(_ActionModule):
|
||||||
|
|
||||||
def run(self, tmp=None, task_vars=None):
|
def run(self, tmp=None, task_vars=None):
|
||||||
|
|
||||||
if self._play_context.connection != 'local':
|
if self._play_context.connection != 'local':
|
||||||
return dict(
|
return dict(
|
||||||
failed=True,
|
failed=True,
|
||||||
|
@ -114,6 +113,3 @@ class ActionModule(_ActionModule):
|
||||||
return strategy(*args, **kwargs)
|
return strategy(*args, **kwargs)
|
||||||
except AnsibleFallbackNotFound:
|
except AnsibleFallbackNotFound:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -43,10 +43,7 @@ class ActionModule(_ActionModule):
|
||||||
except ValueError as exc:
|
except ValueError as exc:
|
||||||
return dict(failed=True, msg=exc.message)
|
return dict(failed=True, msg=exc.message)
|
||||||
|
|
||||||
if self._play_context.connection == 'local':
|
result = super(ActionModule, self).run(tmp, task_vars)
|
||||||
result = self.normal(tmp, task_vars)
|
|
||||||
else:
|
|
||||||
result = super(ActionModule, self).run(tmp, task_vars)
|
|
||||||
|
|
||||||
if self._task.args.get('backup') and result.get('__backup__'):
|
if self._task.args.get('backup') and result.get('__backup__'):
|
||||||
# User requested backup and no error occurred in module.
|
# User requested backup and no error occurred in module.
|
||||||
|
@ -64,22 +61,6 @@ class ActionModule(_ActionModule):
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def normal(self, tmp=None, task_vars=None):
|
|
||||||
if task_vars is None:
|
|
||||||
task_vars = dict()
|
|
||||||
|
|
||||||
#results = super(ActionModule, self).run(tmp, task_vars)
|
|
||||||
# remove as modules might hide due to nolog
|
|
||||||
#del results['invocation']['module_args']
|
|
||||||
|
|
||||||
results = {}
|
|
||||||
results = merge_hash(results, self._execute_module(tmp=tmp, task_vars=task_vars))
|
|
||||||
|
|
||||||
# hack to keep --verbose from showing all the setup module results
|
|
||||||
if self._task.action == 'setup':
|
|
||||||
results['_ansible_verbose_override'] = True
|
|
||||||
|
|
||||||
return results
|
|
||||||
def _get_working_path(self):
|
def _get_working_path(self):
|
||||||
cwd = self._loader.get_basedir()
|
cwd = self._loader.get_basedir()
|
||||||
if self._task._role is not None:
|
if self._task._role is not None:
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
- "result.changed == true"
|
- "result.changed == true"
|
||||||
- "'set system host-name foo' in result.updates"
|
- "'set system host-name foo' in result.commands"
|
||||||
|
|
||||||
- name: collect system commits
|
- name: collect system commits
|
||||||
vyos_command:
|
vyos_command:
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
- "result.changed == true"
|
- "result.changed == true"
|
||||||
- "'set system host-name foo' in result.updates"
|
- "'set system host-name foo' in result.commands"
|
||||||
|
|
||||||
- name: check simple config command idempontent
|
- name: check simple config command idempontent
|
||||||
vyos_config:
|
vyos_config:
|
||||||
|
|
Loading…
Reference in a new issue