mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Ios logging (#33151)
* ios_logging: Handle IOS versions that dont put the word host in logging config This change allows the ansible module to parse and match either variant being present in running-config. * ios_logging: enhance logging buffered to handle both size and level This change allows ios_logging to ensure local (buffered) logging is configured with both the correct buffer size and logging level, when both are specified on the task.
This commit is contained in:
parent
39af276639
commit
e802b769e6
1 changed files with 19 additions and 2 deletions
|
@ -169,7 +169,10 @@ def map_obj_to_commands(updates, module):
|
||||||
commands.append('logging on')
|
commands.append('logging on')
|
||||||
|
|
||||||
elif dest == 'buffered' and size:
|
elif dest == 'buffered' and size:
|
||||||
commands.append('logging buffered {0}'.format(size))
|
if level and level != 'debugging':
|
||||||
|
commands.append('logging buffered {0} {1}'.format(size, level))
|
||||||
|
else:
|
||||||
|
commands.append('logging buffered {0}'.format(size))
|
||||||
|
|
||||||
else:
|
else:
|
||||||
dest_cmd = 'logging {0}'.format(dest)
|
dest_cmd = 'logging {0}'.format(dest)
|
||||||
|
@ -229,7 +232,11 @@ def parse_level(line, dest):
|
||||||
level = 'debugging'
|
level = 'debugging'
|
||||||
|
|
||||||
else:
|
else:
|
||||||
match = re.search(r'logging {0} (\S+)'.format(dest), line, re.M)
|
if dest == 'buffered':
|
||||||
|
match = re.search(r'logging buffered (?:\d+ )([a-z]+)', line, re.M)
|
||||||
|
else:
|
||||||
|
match = re.search(r'logging {0} (\S+)'.format(dest), line, re.M)
|
||||||
|
|
||||||
if match:
|
if match:
|
||||||
if match.group(1) in level_group:
|
if match.group(1) in level_group:
|
||||||
level = match.group(1)
|
level = match.group(1)
|
||||||
|
@ -260,6 +267,16 @@ def map_config_to_obj(module):
|
||||||
'facility': parse_facility(line, dest),
|
'facility': parse_facility(line, dest),
|
||||||
'level': parse_level(line, dest)
|
'level': parse_level(line, dest)
|
||||||
})
|
})
|
||||||
|
else:
|
||||||
|
ip_match = re.search(r'\d+\.\d+\.\d+\.\d+', match.group(1), re.M)
|
||||||
|
if ip_match:
|
||||||
|
dest = 'host'
|
||||||
|
obj.append({
|
||||||
|
'dest': dest,
|
||||||
|
'name': match.group(1),
|
||||||
|
'facility': parse_facility(line, dest),
|
||||||
|
'level': parse_level(line, dest)
|
||||||
|
})
|
||||||
return obj
|
return obj
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue