|
|
|
@ -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
|
|
|
|
|