Do not re.search show configuration stdout if empty (#23087)
If the banner is not set, the stdout of 'show configuration | begin banner <banner>' returns empty string thus the re.search raises an exception. Fixes #22216
This commit is contained in:
parent
88ce6fd273
commit
66e29f0a7c
1 changed files with 4 additions and 1 deletions
|
@ -113,7 +113,10 @@ def map_config_to_obj(module):
|
|||
rc, out, err = exec_command(module,
|
||||
'show running-config | begin banner %s'
|
||||
% module.params['banner'])
|
||||
output = re.search('\^C(.*)\^C', out, re.S).group(1).strip()
|
||||
if out:
|
||||
output = re.search('\^C(.*)\^C', out, re.S).group(1).strip()
|
||||
else:
|
||||
output = None
|
||||
obj = {'banner': module.params['banner'], 'state': 'absent'}
|
||||
if output:
|
||||
obj['text'] = output
|
||||
|
|
Loading…
Reference in a new issue