roll up of updates to asa_template
This updates the asa_template module with updates for Ansible 2.2. * removes get_module() in favor of NetworkModule * fixes up import statements
This commit is contained in:
parent
7b4f78798e
commit
44733e3798
1 changed files with 11 additions and 14 deletions
|
@ -19,7 +19,7 @@ DOCUMENTATION = """
|
||||||
---
|
---
|
||||||
module: asa_template
|
module: asa_template
|
||||||
version_added: "2.2"
|
version_added: "2.2"
|
||||||
author: "Peter Sprygada (@privateip) & Patrick Ogenstad (@ogenstad)"
|
author: "Peter Sprygada (@privateip), Patrick Ogenstad (@ogenstad)"
|
||||||
short_description: Manage Cisco ASA device configurations over SSH
|
short_description: Manage Cisco ASA device configurations over SSH
|
||||||
description:
|
description:
|
||||||
- Manages Cisco ASA network device configurations over SSH. This module
|
- Manages Cisco ASA network device configurations over SSH. This module
|
||||||
|
@ -115,15 +115,15 @@ responses:
|
||||||
type: list
|
type: list
|
||||||
sample: ['...', '...']
|
sample: ['...', '...']
|
||||||
"""
|
"""
|
||||||
|
from ansible.module_utils.netcfg import NetworkConfig, dumps
|
||||||
|
from ansible.module_utils.asa import NetworkModule, NetworkError
|
||||||
|
|
||||||
def get_config(module):
|
def get_config(module):
|
||||||
config = module.params['config'] or dict()
|
config = module.params['config'] or dict()
|
||||||
if not config and not module.params['force']:
|
if not config and not module.params['force']:
|
||||||
config = module.config
|
config = module.config.get_config()
|
||||||
return config
|
return config
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
""" main entry point for module execution
|
""" main entry point for module execution
|
||||||
"""
|
"""
|
||||||
|
@ -138,7 +138,7 @@ def main():
|
||||||
|
|
||||||
mutually_exclusive = [('config', 'backup'), ('config', 'force')]
|
mutually_exclusive = [('config', 'backup'), ('config', 'force')]
|
||||||
|
|
||||||
module = get_module(argument_spec=argument_spec,
|
module = NetworkModule(argument_spec=argument_spec,
|
||||||
mutually_exclusive=mutually_exclusive,
|
mutually_exclusive=mutually_exclusive,
|
||||||
supports_check_mode=True)
|
supports_check_mode=True)
|
||||||
|
|
||||||
|
@ -149,17 +149,18 @@ def main():
|
||||||
contents = get_config(module)
|
contents = get_config(module)
|
||||||
if contents:
|
if contents:
|
||||||
config = NetworkConfig(contents=contents, indent=1)
|
config = NetworkConfig(contents=contents, indent=1)
|
||||||
result['_backup'] = contents
|
result['_backup'] = str(contents)
|
||||||
|
|
||||||
if not module.params['force']:
|
if not module.params['force']:
|
||||||
commands = candidate.difference(config)
|
commands = candidate.difference(config)
|
||||||
|
commands = dumps(commands, 'commands').split('\n')
|
||||||
|
commands = [str(c) for c in commands if c]
|
||||||
else:
|
else:
|
||||||
commands = str(candidate).split('\n')
|
commands = str(candidate).split('\n')
|
||||||
|
|
||||||
if commands:
|
if commands:
|
||||||
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
|
||||||
|
|
||||||
|
@ -167,9 +168,5 @@ def main():
|
||||||
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()
|
||||||
|
|
Loading…
Reference in a new issue