From b1d297d1443c79e88ad0a5a4333aa2d8d4b2a982 Mon Sep 17 00:00:00 2001 From: Peter Sprygada Date: Thu, 17 Aug 2017 07:48:35 -0400 Subject: [PATCH] fixes asa_acl module to work with persistent connections (#28320) * updates module_utils/asa.py to add missing common argument 'passwords' * fixes asa_acl.py module to work with persistent connections --- lib/ansible/module_utils/asa.py | 3 ++- lib/ansible/modules/network/asa/asa_acl.py | 30 +++++++++++----------- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/lib/ansible/module_utils/asa.py b/lib/ansible/module_utils/asa.py index 199ab99a08d..2a95174c784 100644 --- a/lib/ansible/module_utils/asa.py +++ b/lib/ansible/module_utils/asa.py @@ -43,7 +43,8 @@ asa_argument_spec = { 'auth_pass': dict(fallback=(env_fallback, ['ANSIBLE_NET_AUTH_PASS']), no_log=True), 'timeout': dict(type='int'), 'provider': dict(type='dict'), - 'context': dict() + 'context': dict(), + 'passwords': dict() } command_spec = { diff --git a/lib/ansible/modules/network/asa/asa_acl.py b/lib/ansible/modules/network/asa/asa_acl.py index fc3bbb4f113..2601ae0fd85 100644 --- a/lib/ansible/modules/network/asa/asa_acl.py +++ b/lib/ansible/modules/network/asa/asa_acl.py @@ -130,23 +130,19 @@ updates: description: The set of commands that will be pushed to the remote device returned: always type: list - sample: ['...', '...'] - -responses: - description: The set of responses from issuing the commands on the device - returned: when not check_mode - type: list - sample: ['...', '...'] + sample: ['access-list ACL-OUTSIDE extended permit tcp any any eq www'] """ +from ansible.module_utils.basic import AnsibleModule +from ansible.module_utils.asa import asa_argument_spec, check_args +from ansible.module_utils.asa import get_config, load_config, run_commands -from ansible.module_utils.network import NetworkModule from ansible.module_utils.netcfg import NetworkConfig, dumps -def get_config(module, acl_name): +def get_acl_config(module, acl_name): contents = module.params['config'] if not contents: - contents = module.config.get_config() + contents = get_config(module) filtered_config = list() for item in contents.split('\n'): @@ -176,20 +172,25 @@ def main(): argument_spec = dict( lines=dict(aliases=['commands'], required=True, type='list'), + before=dict(type='list'), after=dict(type='list'), + match=dict(default='line', choices=['line', 'strict', 'exact']), replace=dict(default='line', choices=['line', 'block']), + force=dict(default=False, type='bool'), config=dict() ) - module = NetworkModule(argument_spec=argument_spec, + argument_spec.update(asa_argument_spec) + + module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) lines = module.params['lines'] - result = dict(changed=False) + result = {'changed': False} candidate = NetworkConfig(indent=1) candidate.add(lines) @@ -197,7 +198,7 @@ def main(): acl_name = parse_acl_name(module) if not module.params['force']: - contents = get_config(module, acl_name) + contents = get_acl_config(module, acl_name) config = NetworkConfig(indent=1, contents=contents) commands = candidate.difference(config) @@ -208,8 +209,7 @@ def main(): if commands: if not module.check_mode: - response = module.config(commands) - result['responses'] = response + load_config(module, commands) result['changed'] = True result['updates'] = commands