diff --git a/CHANGELOG.md b/CHANGELOG.md index 019224a..d3d3a63 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,19 @@ +# CHANGELOG + + +## [0.9.4] + +### Added +- [#236] Add support for **connection_args in ntc_config_command + + ## [0.9.3] + ### Fixed - [#262] Account for Ansible Versions beyond 2.9 + ## [0.9.2] + ### Fixed - [#256] Made setup.py work with python2.7 again - diff --git a/library/ntc_config_command.py b/library/ntc_config_command.py index 74c669f..c0bd57f 100644 --- a/library/ntc_config_command.py +++ b/library/ntc_config_command.py @@ -33,6 +33,11 @@ required: false default: ssh choices: ['ssh', 'telnet'] + connection_args: + description: + - Transport parameters specific to netmiko, trigger, etc. + required: false + default: {} platform: description: - Platform FROM the index file @@ -178,6 +183,7 @@ def main(): secret=dict(required=False, type='str', no_log=True), use_keys=dict(required=False, default=False, type='bool'), key_file=dict(required=False, default=None), + connection_args=dict(required=False, type='dict', default={}), ) base_argument_spec = dict( commands=dict(required=False, type='list'), @@ -213,9 +219,9 @@ def main(): secret = module.params['secret'] use_keys = module.params['use_keys'] key_file = module.params['key_file'] + connection_args = module.params['connection_args'] - - argument_check = { 'host': host, 'username': username, 'platform': platform, 'password': password } + argument_check = {'host': host, 'username': username, 'platform': platform, 'password': password} for key, val in argument_check.items(): if val is None: module.fail_json(msg=str(key) + " is required") @@ -224,8 +230,7 @@ def main(): host = socket.gethostbyname(module.params['host']) if connection == 'telnet' and platform != 'cisco_ios': - module.fail_json(msg='only cisco_ios supports ' - 'telnet connection') + module.fail_json(msg='only cisco_ios supports telnet connection') if platform == 'cisco_ios' and connection == 'telnet': device_type = 'cisco_ios_telnet' @@ -239,16 +244,20 @@ def main(): port = 22 if connection in ['ssh', 'telnet']: - device = ConnectHandler(device_type=device_type, - ip=socket.gethostbyname(host), - port=port, - username=username, - password=password, - secret=secret, - use_keys=use_keys, - key_file=key_file - ) - + device_args = dict( + device_type=device_type, + ip=socket.gethostbyname(host), + port=port, + username=username, + password=password, + secret=secret, + use_keys=use_keys, + key_file=key_file, + ) + if connection_args: + device_args.update(connection_args) + + device = ConnectHandler(**device_args) if secret: device.enable() @@ -264,8 +273,7 @@ def main(): module.fail_json(msg="Unable to locate: {}".format(commands_file)) if (error_params(platform, output)): - module.fail_json(msg="Error executing command:\ - {}".format(output)) + module.fail_json(msg="Error executing command: {}".format(output)) results = {} results['response'] = output diff --git a/library/ntc_show_command.py b/library/ntc_show_command.py index 1a092ab..99640fc 100644 --- a/library/ntc_show_command.py +++ b/library/ntc_show_command.py @@ -46,7 +46,7 @@ choices: ['ssh', 'offline', 'netmiko_ssh', 'trigger_ssh', 'netmiko_telnet', 'telnet'] connection_args: description: - - Transport parameters specific to netmiko, trigger, etc. + - Transport parameters specific to netmiko. required: false default: {} platform: