@ -121,7 +121,6 @@ commands:
import re
from copy import deepcopy
from ansible . module_utils . basic import AnsibleModule
from ansible . module_utils . network . common . utils import remove_default_spec , validate_ip_address
from ansible . module_utils . network . ios . ios import get_config , load_config
@ -138,6 +137,7 @@ def validate_size(value, module):
def map_obj_to_commands ( updates , module , os_version ) :
dest_group = ( ' console ' , ' monitor ' , ' buffered ' , ' on ' )
commands = list ( )
want , have = updates
for w in want :
@ -149,14 +149,20 @@ def map_obj_to_commands(updates, module, os_version):
state = w [ ' state ' ]
del w [ ' state ' ]
if facility :
w [ ' dest ' ] = ' facility '
if state == ' absent ' and w in have :
if dest :
if dest == ' host ' :
if ' 12. ' in os_version :
commands . append ( ' no logging {0} ' . format ( name ) )
else :
commands . append ( ' no logging host {0} ' . format ( name ) )
elif dest :
elif dest in dest_group :
commands . append ( ' no logging {0} ' . format ( dest ) )
else :
module . fail_json ( msg = ' dest must be among console, monitor, buffered, host, on ' )
@ -165,6 +171,13 @@ def map_obj_to_commands(updates, module, os_version):
if state == ' present ' and w not in have :
if facility :
present = False
for entry in have :
if entry [ ' dest ' ] == ' facility ' and entry [ ' facility ' ] == facility :
present = True
if not present :
commands . append ( ' logging facility {0} ' . format ( facility ) )
if dest == ' host ' :
@ -177,6 +190,13 @@ def map_obj_to_commands(updates, module, os_version):
commands . append ( ' logging on ' )
elif dest == ' buffered ' and size :
present = False
for entry in have :
if entry [ ' dest ' ] == ' buffered ' and entry [ ' size ' ] == size and entry [ ' level ' ] == level :
present = True
if not present :
if level and level != ' debugging ' :
commands . append ( ' logging buffered {0} {1} ' . format ( size , level ) )
else :
@ -293,7 +313,6 @@ def map_config_to_obj(module):
' facility ' : parse_facility ( line , dest ) ,
' level ' : parse_level ( line , dest )
} )
return obj
@ -355,7 +374,6 @@ def map_params_to_obj(module, required_if=None):
' level ' : module . params [ ' level ' ] ,
' state ' : module . params [ ' state ' ]
} )
return obj
@ -412,5 +430,6 @@ def main():
module . exit_json ( * * result )
if __name__ == ' __main__ ' :
main ( )