From 895c8ce37341521582c413f0ad071de8e64cb6b7 Mon Sep 17 00:00:00 2001 From: Rishabh Saxena Date: Wed, 11 Dec 2019 07:32:05 +0000 Subject: [PATCH] Fixed bug when asa_acl terminates when lines array is empty (#63838) * Fixed bug when asa_acl terminates when lines array is empty * Removed redundant blank lines --- lib/ansible/modules/network/asa/asa_acl.py | 42 +++++++++++----------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/lib/ansible/modules/network/asa/asa_acl.py b/lib/ansible/modules/network/asa/asa_acl.py index 8f12e617ae5..5bdec49a0bd 100644 --- a/lib/ansible/modules/network/asa/asa_acl.py +++ b/lib/ansible/modules/network/asa/asa_acl.py @@ -185,35 +185,35 @@ def main(): lines = module.params['lines'] result = {'changed': False} + if len(lines) > 0: + candidate = NetworkConfig(indent=1) + candidate.add(lines) - candidate = NetworkConfig(indent=1) - candidate.add(lines) + acl_name = parse_acl_name(module) - acl_name = parse_acl_name(module) + if not module.params['force']: + contents = get_acl_config(module, acl_name) + config = NetworkConfig(indent=1, contents=contents) - if not module.params['force']: - contents = get_acl_config(module, acl_name) - config = NetworkConfig(indent=1, contents=contents) + commands = candidate.difference(config) + commands = dumps(commands, 'commands').split('\n') + commands = [str(c) for c in commands if c] + else: + commands = str(candidate).split('\n') - commands = candidate.difference(config) - commands = dumps(commands, 'commands').split('\n') - commands = [str(c) for c in commands if c] - else: - commands = str(candidate).split('\n') + if commands: + if module.params['before']: + commands[:0] = module.params['before'] - if commands: - if module.params['before']: - commands[:0] = module.params['before'] + if module.params['after']: + commands.extend(module.params['after']) - if module.params['after']: - commands.extend(module.params['after']) + if not module.check_mode: + load_config(module, commands) - if not module.check_mode: - load_config(module, commands) + result['changed'] = True - result['changed'] = True - - result['updates'] = commands + result['updates'] = commands module.exit_json(**result)