mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
parent
87f004c503
commit
1152f86ba1
5 changed files with 13 additions and 11 deletions
|
@ -1,5 +1,6 @@
|
||||||
#
|
#
|
||||||
# (c) 2015 Peter Sprygada, <psprygada@ansible.com>
|
# (c) 2015 Peter Sprygada, <psprygada@ansible.com>
|
||||||
|
# (c) 2017 Red Hat, Inc
|
||||||
#
|
#
|
||||||
# Copyright (c) 2016 Dell Inc.
|
# Copyright (c) 2016 Dell Inc.
|
||||||
#
|
#
|
||||||
|
@ -122,6 +123,7 @@ def load_config(module, commands):
|
||||||
for command in to_list(commands):
|
for command in to_list(commands):
|
||||||
if command == 'end':
|
if command == 'end':
|
||||||
continue
|
continue
|
||||||
|
# cmd = {'command': command, 'prompt': WARNING_PROMPTS_RE, 'answer': 'yes'}
|
||||||
rc, out, err = exec_command(module, command)
|
rc, out, err = exec_command(module, command)
|
||||||
if rc != 0:
|
if rc != 0:
|
||||||
module.fail_json(msg=to_text(err, errors='surrogate_or_strict'), command=command, rc=rc)
|
module.fail_json(msg=to_text(err, errors='surrogate_or_strict'), command=command, rc=rc)
|
||||||
|
@ -168,7 +170,7 @@ def os6_parse(lines, indent=None, comment_tokens=None):
|
||||||
re.compile(r'template.*$'),
|
re.compile(r'template.*$'),
|
||||||
re.compile(r'address-family.*$'),
|
re.compile(r'address-family.*$'),
|
||||||
re.compile(r'spanning-tree mst configuration.*$'),
|
re.compile(r'spanning-tree mst configuration.*$'),
|
||||||
re.compile(r'logging.*$'),
|
re.compile(r'logging (?!.*(cli-command|buffered|console|email|facility|file|monitor|protocol|snmp|source-interface|traps|web-session)).*$'),
|
||||||
re.compile(r'(radius-server|tacacs-server) host.*$')]
|
re.compile(r'(radius-server|tacacs-server) host.*$')]
|
||||||
|
|
||||||
childline = re.compile(r'^exit$')
|
childline = re.compile(r'^exit$')
|
||||||
|
|
|
@ -263,7 +263,7 @@ def main():
|
||||||
commands = dumps(configobjs, 'commands')
|
commands = dumps(configobjs, 'commands')
|
||||||
if ((isinstance((module.params['lines']), list)) and
|
if ((isinstance((module.params['lines']), list)) and
|
||||||
(isinstance((module.params['lines'][0]), dict)) and
|
(isinstance((module.params['lines'][0]), dict)) and
|
||||||
(['prompt', 'answer'].issubset(module.params['lines'][0]))):
|
(set(['prompt', 'answer']).issubset(module.params['lines'][0]))):
|
||||||
|
|
||||||
cmd = {'command': commands,
|
cmd = {'command': commands,
|
||||||
'prompt': module.params['lines'][0]['prompt'],
|
'prompt': module.params['lines'][0]['prompt'],
|
||||||
|
|
|
@ -262,7 +262,7 @@ def main():
|
||||||
commands = dumps(configobjs, 'commands')
|
commands = dumps(configobjs, 'commands')
|
||||||
if ((isinstance(module.params['lines'], list)) and
|
if ((isinstance(module.params['lines'], list)) and
|
||||||
(isinstance(module.params['lines'][0], dict)) and
|
(isinstance(module.params['lines'][0], dict)) and
|
||||||
['prompt', 'answer'].issubset(module.params['lines'][0])):
|
set(['prompt', 'answer']).issubset(module.params['lines'][0])):
|
||||||
cmd = {'command': commands,
|
cmd = {'command': commands,
|
||||||
'prompt': module.params['lines'][0]['prompt'],
|
'prompt': module.params['lines'][0]['prompt'],
|
||||||
'answer': module.params['lines'][0]['answer']}
|
'answer': module.params['lines'][0]['answer']}
|
||||||
|
@ -287,7 +287,7 @@ def main():
|
||||||
result['changed'] = True
|
result['changed'] = True
|
||||||
if not module.check_mode:
|
if not module.check_mode:
|
||||||
cmd = {'command': 'copy running-config startup-config',
|
cmd = {'command': 'copy running-config startup-config',
|
||||||
'prompt': r'\(y/n\)$', 'answer': 'yes'}
|
'prompt': r'\(y/n\)\s?$', 'answer': 'yes'}
|
||||||
run_commands(module, [cmd])
|
run_commands(module, [cmd])
|
||||||
result['saved'] = True
|
result['saved'] = True
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -270,7 +270,7 @@ def main():
|
||||||
commands = dumps(configobjs, 'commands')
|
commands = dumps(configobjs, 'commands')
|
||||||
if ((isinstance(module.params['lines'], list)) and
|
if ((isinstance(module.params['lines'], list)) and
|
||||||
(isinstance(module.params['lines'][0], dict)) and
|
(isinstance(module.params['lines'][0], dict)) and
|
||||||
['prompt', 'answer'].issubset(module.params['lines'][0])):
|
set(['prompt', 'answer']).issubset(module.params['lines'][0])):
|
||||||
|
|
||||||
cmd = {'command': commands,
|
cmd = {'command': commands,
|
||||||
'prompt': module.params['lines'][0]['prompt'],
|
'prompt': module.params['lines'][0]['prompt'],
|
||||||
|
|
|
@ -37,17 +37,17 @@ class TerminalModule(TerminalBase):
|
||||||
]
|
]
|
||||||
|
|
||||||
terminal_stderr_re = [
|
terminal_stderr_re = [
|
||||||
re.compile(br"% ?Error: (?:(?!\bdoes not exist\b)(?!\balready exists\b)(?!\bHost not found\b)(?!\bnot active\b).)*$"),
|
|
||||||
re.compile(br"% ?Bad secret"),
|
re.compile(br"% ?Bad secret"),
|
||||||
re.compile(br"(\bInterface is part of a port-channel\b)|(\bAn invalid interface has been used for this function\b)"),
|
re.compile(br"(\bInterface is part of a port-channel\b)"),
|
||||||
re.compile(br"(\bThe maximum number of users have already been created\b)|(\bVLAN ID is out of range\b)|(\bUse '-' for range\b)"),
|
re.compile(br"(\bThe maximum number of users have already been created\b)|(\bUse '-' for range\b)"),
|
||||||
re.compile(br"(\binvalid input\b)|(\bVLAN ID not found\b)"),
|
|
||||||
re.compile(br"(\bInvalid access level. Access level can be either 0, 1 or 15\b)|(\bValue is out of range\b)"),
|
|
||||||
re.compile(br"Cannot add(.+)\s(\S+)"),
|
|
||||||
re.compile(br"Error:(.+)\s(\S+)"),
|
re.compile(br"Error:(.+)\s(\S+)"),
|
||||||
re.compile(br"(?:incomplete|ambiguous) command", re.I),
|
re.compile(br"(?:incomplete|ambiguous) command", re.I),
|
||||||
re.compile(br"connection timed out", re.I),
|
re.compile(br"connection timed out", re.I),
|
||||||
re.compile(br"'[^']' +returned error code: ?\d+"),
|
re.compile(br"'[^']' +returned error code: ?\d+"),
|
||||||
|
re.compile(br"Invalid|invalid.*$", re.I),
|
||||||
|
re.compile(br"((\bout of range\b)|(\bnot found\b)|(\bCould not\b)|(\bUnable to\b)|(\bCannot\b)).*", re.I),
|
||||||
|
re.compile(br"((\balready exists\b)|(\bdoes not exist\b)|(\bnot active\b)|(\bFailed\b)|(\bIncorrect\b)|(\bnot enabled\b)).*", re.I),
|
||||||
|
|
||||||
]
|
]
|
||||||
|
|
||||||
def on_become(self, passwd=None):
|
def on_become(self, passwd=None):
|
||||||
|
|
Loading…
Reference in a new issue