diff options
author | Peter Sprygada <privateip@users.noreply.github.com> | 2016-07-13 14:50:53 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-07-13 14:50:53 -0700 |
commit | f7d1e37c5349c9f00d9496a58b8b025aeed0755b (patch) | |
tree | 022897ac204814a210eb5b86d2ac7d0e74f48c93 | |
parent | 8e241a87cc69e938188c5c1a8e024ac05c66b712 (diff) | |
parent | d8d69904a75dac2e079b2eef5b99a2deaf0f81ec (diff) | |
download | ansible-modules-core-f7d1e37c5349c9f00d9496a58b8b025aeed0755b.tar.gz |
Merge pull request #4154 from privateip/ios_template
fixup ios_template module to use NetworkModule
-rw-r--r-- | network/ios/ios_template.py | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/network/ios/ios_template.py b/network/ios/ios_template.py index 9452b3d3..6d8a9761 100644 --- a/network/ios/ios_template.py +++ b/network/ios/ios_template.py @@ -19,7 +19,7 @@ DOCUMENTATION = """ --- module: ios_template version_added: "2.1" -author: "Peter sprygada (@privateip)" +author: "Peter Sprygada (@privateip)" short_description: Manage Cisco IOS device configurations over SSH description: - Manages Cisco IOS network device configurations over SSH. This module @@ -115,11 +115,13 @@ responses: type: list sample: ['...', '...'] """ +from ansible.module_utils.netcfg import NetworkConfig, dumps +from ansible.module_utils.ios import NetworkModule, NetworkError def get_config(module): config = module.params['config'] or dict() if not config and not module.params['force']: - config = module.config + config = module.config.get_config() return config def main(): @@ -136,9 +138,9 @@ def main(): mutually_exclusive = [('config', 'backup'), ('config', 'force')] - module = get_module(argument_spec=argument_spec, - mutually_exclusive=mutually_exclusive, - supports_check_mode=True) + module = NetworkModule(argument_spec=argument_spec, + mutually_exclusive=mutually_exclusive, + supports_check_mode=True) result = dict(changed=False) @@ -149,15 +151,16 @@ def main(): config = NetworkConfig(contents=contents, indent=1) result['_backup'] = contents + commands = list() if not module.params['force']: - commands = candidate.difference(config) + commands = dumps(candidate.difference(config), 'commands') else: - commands = str(candidate).split('\n') + commands = str(candidate) if commands: + commands = commands.split('\n') if not module.check_mode: - commands = [str(c).strip() for c in commands] - response = module.configure(commands) + response = module.config(commands) result['responses'] = response result['changed'] = True @@ -165,10 +168,6 @@ def main(): 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.ios import * if __name__ == '__main__': main() |