mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
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
This commit is contained in:
parent
86f23dc620
commit
b1d297d144
2 changed files with 17 additions and 16 deletions
|
@ -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 = {
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue