Repository: ansible/ansible

Issue:
netconf_config module is missing options
<!---
Verify first that your issue/request is not already reported on GitHub.
Also test if the latest release, and master branch are affected too.
-->

##### ISSUE TYPE
<!--- Pick one below and delete the rest: -->
 - Bug Report

##### COMPONENT NAME
<!--- Name of the module/plugin/task/feature -->
netconf_config

##### ANSIBLE VERSION
<!--- Paste verbatim output from “ansible --version” between quotes below -->
```
ansible 2.2.1.0
  config file =
  configured module search path = Default w/o overrides
```

##### CONFIGURATION
<!---
Mention any settings you have changed/added/removed in ansible.cfg
(or using the ANSIBLE_* environment variables).
-->
N/A

##### OS / ENVIRONMENT
<!---
Mention the OS you are running Ansible from, and the OS you are
managing, or say “N/A” for anything that is not platform-specific.
-->
macOS 10.12.3

##### SUMMARY
<!--- Explain the problem briefly -->
netconf_config module has some options but it does not have all options required to make netconf work in specific scenarios, specifically it is missing the `look_for_keys` and `allow_agent`, this prevents connecting to some devices via netconf

##### STEPS TO REPRODUCE
<!---
For bugs, show exactly how to reproduce the problem, using a minimal test-case.
For new features, show how the feature would be used.
-->
Executing the playbook with the options that we have today does not allow for me to connect to the remote system via netconf.

<!--- Paste example playbooks or commands between quotes below -->
```yaml
---
- hosts: localhost
  connection: local
  tasks:
    - name: change something on nso
      netconf_config:
        host: 10.201.36.121
        username: admin
        password: changeme
        hostkey_verify: false
        xml: |
            <?xml version="1.0" encoding="UTF-8"?>
            <rpc message-id="1" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
              <get-config>
                <source>
                  <running/>
                </source>
                <filter select=" /nacm/groups" type="xpath"/>
              </get-config>
            </rpc>
```

<!--- You can also paste gist.github.com links for larger files -->

##### EXPECTED RESULTS
<!--- What did you expect to happen when running the steps above? -->
Connection successfull and configuration applied.

##### ACTUAL RESULTS
<!--- What actually happened? If possible run with extra verbosity (-vvvv) -->
Got `error connecting to the device: Negotiation failed`

<!--- Paste verbatim command output between quotes below -->
```
No config file found; using defaults
 [WARNING]: Host file not found: /etc/ansible/hosts

 [WARNING]: provided hosts list is empty, only localhost is available

Loading callback plugin default of type stdout, v2.0 from /Users/userlerueda/Documents/virtualenv/default-py2/lib/python2.7/site-packages/ansible/plugins/callback/__init__.pyc

PLAYBOOK: site.yml *************************************************************
1 plays in site.yml

PLAY [localhost] ***************************************************************

TASK [setup] *******************************************************************
Using module file /Users/userlerueda/Documents/virtualenv/default-py2/lib/python2.7/site-packages/ansible/modules/core/system/setup.py
<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: userlerueda
<127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo ~/.ansible/tmp/ansible-tmp-1488984687.56-194813298644492 `" && echo ansible-tmp-1488984687.56-194813298644492="` echo ~/.ansible/tmp/ansible-tmp-1488984687.56-194813298644492 `" ) && sleep 0'
<127.0.0.1> PUT /var/folders/lc/3qb2k8c57vx0rj94q5p1vqkr0000gn/T/tmpeuQgf5 TO /Users/userlerueda/.ansible/tmp/ansible-tmp-1488984687.56-194813298644492/setup.py
<127.0.0.1> EXEC /bin/sh -c 'chmod u+x /Users/userlerueda/.ansible/tmp/ansible-tmp-1488984687.56-194813298644492/ /Users/userlerueda/.ansible/tmp/ansible-tmp-1488984687.56-194813298644492/setup.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '/Users/userlerueda/Documents/virtualenv/default-py2/bin/python2.7 /Users/userlerueda/.ansible/tmp/ansible-tmp-1488984687.56-194813298644492/setup.py; rm -rf "/Users/userlerueda/.ansible/tmp/ansible-tmp-1488984687.56-194813298644492/" > /dev/null 2>&1 && sleep 0'
ok: [localhost]

TASK [change something on nso] *************************************************
task path: /Users/userlerueda/Documents/github3/NFV-VMS/netconf_access/site.yml:5
Using module file /Users/userlerueda/Documents/virtualenv/default-py2/lib/python2.7/site-packages/ansible/modules/extras/network/netconf/netconf_config.py
<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: userlerueda
<127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo ~/.ansible/tmp/ansible-tmp-1488984688.31-26526904820982 `" && echo ansible-tmp-1488984688.31-26526904820982="` echo ~/.ansible/tmp/ansible-tmp-1488984688.31-26526904820982 `" ) && sleep 0'
<127.0.0.1> PUT /var/folders/lc/3qb2k8c57vx0rj94q5p1vqkr0000gn/T/tmpomIynz TO /Users/userlerueda/.ansible/tmp/ansible-tmp-1488984688.31-26526904820982/netconf_config.py
<127.0.0.1> EXEC /bin/sh -c 'chmod u+x /Users/userlerueda/.ansible/tmp/ansible-tmp-1488984688.31-26526904820982/ /Users/userlerueda/.ansible/tmp/ansible-tmp-1488984688.31-26526904820982/netconf_config.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '/Users/userlerueda/Documents/virtualenv/default-py2/bin/python2.7 /Users/userlerueda/.ansible/tmp/ansible-tmp-1488984688.31-26526904820982/netconf_config.py; rm -rf "/Users/userlerueda/.ansible/tmp/ansible-tmp-1488984688.31-26526904820982/" > /dev/null 2>&1 && sleep 0'
fatal: [localhost]: FAILED! => {
    "changed": false,
    "failed": true,
    "invocation": {
        "module_args": {
            "host": "10.201.36.121",
            "hostkey_verify": false,
            "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
            "port": 830,
            "username": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
            "xml": "<config xmlns=\"http://tail-f.com/ns/config/1.0\">\n  <pnp xmlns=\"http://tail-f.com/ned/cisco/pnp\">\n    <server>\n      <port>4433</port>\n      <use-ssl>true</use-ssl>\n    </server>\n  </pnp>\n</config>\n"
        },
        "module_name": "netconf_config"
    },
    "msg": "error connecting to the device: Negotiation failed"
}
	to retry, use: --limit @/Users/userlerueda/Documents/github3/NFV-VMS/netconf_access/site.retry

PLAY RECAP *********************************************************************
localhost                  : ok=1    changed=0    unreachable=0    failed=1
```



Discussion:
cc @lpenz
[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)
<!--- boilerplate: notify --->
Thanks for identifying the issue, I'll take a look into it
I'm thinking we should expose the `look_for_keys` and `allow_agent` args on ncclient to the netconf_config module, changing those two to false solves my problem. I can submit a PR if you are ok.

Resolving patch:
diff --git a/lib/ansible/modules/network/netconf/netconf_config.py b/lib/ansible/modules/network/netconf/netconf_config.py
--- a/lib/ansible/modules/network/netconf/netconf_config.py
+++ b/lib/ansible/modules/network/netconf/netconf_config.py
@@ -52,6 +52,20 @@
      - if false, the ssh host key of the device is not checked
     default: true
     required: false
+  look_for_keys:
+    description:
+     - if true, enables looking in the usual locations for ssh keys (e.g. ~/.ssh/id_*)
+     - if false, disables looking for ssh keys
+    default: true
+    required: false
+    version_added: "2.3"
+  allow_agent:
+    description:
+     - if true, enables querying SSH agent (if found) for keys
+     - if false, disables querying the SSH agent for ssh keys
+    default: true
+    required: false
+    version_added: "2.3"
   username:
     description:
      - the username to authenticate with
@@ -164,6 +178,8 @@ def main():
             host=dict(type='str', required=True),
             port=dict(type='int', default=830),
             hostkey_verify=dict(type='bool', default=True),
+            allow_agent=dict(type='bool', default=True),
+            look_for_keys=dict(type='bool', default=True),
             username=dict(type='str', required=True, no_log=True),
             password=dict(type='str', required=True, no_log=True),
             xml=dict(type='str', required=True),
@@ -188,6 +204,8 @@ def main():
         host=module.params['host'],
         port=module.params['port'],
         hostkey_verify=module.params['hostkey_verify'],
+        allow_agent=module.params['allow_agent'],
+        look_for_keys=module.params['look_for_keys'],
         username=module.params['username'],
         password=module.params['password'],
     )


Test patch: