|
|
@ -128,6 +128,8 @@ responses:
|
|
|
|
type: list
|
|
|
|
type: list
|
|
|
|
sample: ['...', '...']
|
|
|
|
sample: ['...', '...']
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
|
|
|
|
from ansible.module_utils.netcfg import NetworkConfig
|
|
|
|
|
|
|
|
from ansible.module_utils.asa import NetworkModule
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_config(module):
|
|
|
|
def get_config(module):
|
|
|
@ -166,8 +168,8 @@ def main():
|
|
|
|
config=dict()
|
|
|
|
config=dict()
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
module = get_module(argument_spec=argument_spec,
|
|
|
|
module = NetworkModule(argument_spec=argument_spec,
|
|
|
|
supports_check_mode=True)
|
|
|
|
supports_check_mode=True)
|
|
|
|
|
|
|
|
|
|
|
|
lines = module.params['lines']
|
|
|
|
lines = module.params['lines']
|
|
|
|
|
|
|
|
|
|
|
@ -179,38 +181,22 @@ def main():
|
|
|
|
|
|
|
|
|
|
|
|
module.filter = check_input_acl(lines, module)
|
|
|
|
module.filter = check_input_acl(lines, module)
|
|
|
|
if not module.params['force']:
|
|
|
|
if not module.params['force']:
|
|
|
|
contents = get_config(module)
|
|
|
|
commands = candidate.difference(config)
|
|
|
|
config = NetworkConfig(contents=contents, indent=1)
|
|
|
|
commands = dumps(commands, 'commands').split('\n')
|
|
|
|
|
|
|
|
commands = [str(c) for c in commands if c]
|
|
|
|
candidate = NetworkConfig(indent=1)
|
|
|
|
|
|
|
|
candidate.add(lines)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
commands = candidate.difference(config, match=match, replace=replace)
|
|
|
|
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
commands = []
|
|
|
|
commands = str(candidate).split('\n')
|
|
|
|
commands.extend(lines)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
result = dict(changed=False)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if commands:
|
|
|
|
if commands:
|
|
|
|
if before:
|
|
|
|
|
|
|
|
commands[:0] = before
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if after:
|
|
|
|
|
|
|
|
commands.extend(after)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if not module.check_mode:
|
|
|
|
if not module.check_mode:
|
|
|
|
commands = [str(c).strip() for c in commands]
|
|
|
|
response = module.config(commands)
|
|
|
|
response = module.configure(commands)
|
|
|
|
|
|
|
|
result['responses'] = response
|
|
|
|
result['responses'] = response
|
|
|
|
result['changed'] = True
|
|
|
|
result['changed'] = True
|
|
|
|
|
|
|
|
|
|
|
|
result['updates'] = commands
|
|
|
|
result['updates'] = commands
|
|
|
|
|
|
|
|
|
|
|
|
module.exit_json(**result)
|
|
|
|
module.exit_json(**result)
|
|
|
|
|
|
|
|
|
|
|
|
from ansible.module_utils.basic import *
|
|
|
|
|
|
|
|
from ansible.module_utils.shell import *
|
|
|
|
|
|
|
|
from ansible.module_utils.netcfg import *
|
|
|
|
|
|
|
|
from ansible.module_utils.asa import *
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
if __name__ == '__main__':
|
|
|
|
main()
|
|
|
|
main()
|
|
|
|