@ -461,8 +461,8 @@ def main():
execute ( cmd + [ [ command ] , [ value ] ] )
execute ( cmd + [ [ command ] , [ value ] ] )
elif command == ' default ' :
elif command == ' default ' :
if params [ ' direction ' ] not in [ ' outgoing ' , ' incoming ' , ' routed ' ]:
if params [ ' direction ' ] not in [ ' outgoing ' , ' incoming ' , ' routed ' , None ]:
module . fail_json ( msg = ' For default, direction must be one of " outgoing " , " incoming " and " routed " .' )
module . fail_json ( msg = ' For default, direction must be one of " outgoing " , " incoming " and " routed " , or direction must not be specified .' )
if module . check_mode :
if module . check_mode :
regexp = r ' Default: (deny|allow|reject) \ (incoming \ ), (deny|allow|reject) \ (outgoing \ ), (deny|allow|reject|disabled) \ (routed \ ) '
regexp = r ' Default: (deny|allow|reject) \ (incoming \ ), (deny|allow|reject) \ (outgoing \ ), (deny|allow|reject|disabled) \ (routed \ ) '
extract = re . search ( regexp , pre_state )
extract = re . search ( regexp , pre_state )
@ -471,8 +471,14 @@ def main():
current_default_values [ " incoming " ] = extract . group ( 1 )
current_default_values [ " incoming " ] = extract . group ( 1 )
current_default_values [ " outgoing " ] = extract . group ( 2 )
current_default_values [ " outgoing " ] = extract . group ( 2 )
current_default_values [ " routed " ] = extract . group ( 3 )
current_default_values [ " routed " ] = extract . group ( 3 )
if current_default_values [ params [ ' direction ' ] ] != value :
if params [ ' direction ' ] is None :
changed = True
for v in current_default_values . values ( ) :
if v not in ( value , ' disabled ' ) :
changed = True
else :
v = current_default_values [ params [ ' direction ' ] ]
if v not in ( value , ' disabled ' ) :
changed = True
else :
else :
changed = True
changed = True
else :
else :
@ -480,7 +486,7 @@ def main():
elif command == ' rule ' :
elif command == ' rule ' :
if params [ ' direction ' ] not in [ ' in ' , ' out ' , None ] :
if params [ ' direction ' ] not in [ ' in ' , ' out ' , None ] :
module . fail_json ( msg = ' For rules, direction must be one of " in " and " out " .' )
module . fail_json ( msg = ' For rules, direction must be one of " in " and " out " , or direction must not be specified .' )
# Rules are constructed according to the long format
# Rules are constructed according to the long format
#
#
# ufw [--dry-run] [route] [delete] [insert NUM] allow|deny|reject|limit [in|out on INTERFACE] [log|log-all] \
# ufw [--dry-run] [route] [delete] [insert NUM] allow|deny|reject|limit [in|out on INTERFACE] [log|log-all] \