mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Merge pull request #16727 from privateip/vyos
adds new function to check config for unsupported commands
This commit is contained in:
commit
61b55d81f9
1 changed files with 13 additions and 0 deletions
|
@ -28,6 +28,10 @@ from ansible.module_utils.shell import Shell, ShellError, HAS_PARAMIKO
|
||||||
|
|
||||||
DEFAULT_COMMENT = 'configured by vyos_config'
|
DEFAULT_COMMENT = 'configured by vyos_config'
|
||||||
|
|
||||||
|
FILTERS = [
|
||||||
|
re.compile(r'set system login user \S+ authentication encrypted-password')
|
||||||
|
]
|
||||||
|
|
||||||
def argument_spec():
|
def argument_spec():
|
||||||
return dict(
|
return dict(
|
||||||
running_config=dict(aliases=['config']),
|
running_config=dict(aliases=['config']),
|
||||||
|
@ -68,6 +72,14 @@ def diff_config(candidate, config):
|
||||||
|
|
||||||
return list(updates)
|
return list(updates)
|
||||||
|
|
||||||
|
def check_config(config, result):
|
||||||
|
result['filtered'] = list()
|
||||||
|
for regex in FILTERS:
|
||||||
|
for index, line in enumerate(list(config)):
|
||||||
|
if regex.search(line):
|
||||||
|
result['filtered'].append(line)
|
||||||
|
del config[index]
|
||||||
|
|
||||||
def load_candidate(module, candidate):
|
def load_candidate(module, candidate):
|
||||||
config = get_config(module)
|
config = get_config(module)
|
||||||
|
|
||||||
|
@ -79,6 +91,7 @@ def load_candidate(module, candidate):
|
||||||
result = dict(changed=False)
|
result = dict(changed=False)
|
||||||
|
|
||||||
if updates:
|
if updates:
|
||||||
|
check_config(updates, result)
|
||||||
diff = module.config.load_config(updates)
|
diff = module.config.load_config(updates)
|
||||||
if diff:
|
if diff:
|
||||||
result['diff'] = dict(prepared=diff)
|
result['diff'] = dict(prepared=diff)
|
||||||
|
|
Loading…
Reference in a new issue