Repository: ansible/ansible

Issue:
junos_netconf integration test fails to run succesfully 
<!---
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 -->
junos_netconf
##### ANSIBLE VERSION
<!--- Paste verbatim output from “ansible --version” between quotes below -->
```
2.4
```

##### CONFIGURATION
<!---
Mention any settings you have changed/added/removed in ansible.cfg
(or using the ANSIBLE_* environment variables).
-->

##### 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.
Also mention the specific version of what you are trying to control,
e.g. if this is a network bug the version of firmware on the network device.
-->

##### SUMMARY
<!--- Explain the problem briefly -->
Fails because of changes in PR 23876

##### 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.
-->

<!--- Paste example playbooks or commands between quotes below -->
```yaml

```

<!--- You can also paste gist.github.com links for larger files -->

##### EXPECTED RESULTS
<!--- What did you expect to happen when running the steps above? -->

##### ACTUAL RESULTS
<!--- What actually happened? If possible run with extra verbosity (-vvvv) -->

<!--- Paste verbatim command output between quotes below -->
```
2017-08-22 07:20:27,729 p=1284 u=gnalawad |  TASK [junos_netconf : Ensure we can communicate over             22] *****************************************************
2017-08-22 07:20:27,729 p=1284 u=gnalawad |  task path: /Users/gnalawad/ansible/ganeshrn/ansible/test/        integration/targets/junos_netconf/tests/cli/changeport.yaml:39
2017-08-22 07:20:29,547 p=1435 u=gnalawad |  creating new control socket for host vsrx01:22 as user ansible   2017-08-22 07:20:29,548 p=1435 u=gnalawad |  control socket path is /Users/gnalawad/.ansible/pc/62cd4ef5c0
2017-08-22 07:20:29,548 p=1435 u=gnalawad |  current working directory is /Users/gnalawad/ansible/ganeshrn/   ansible/test/integration
2017-08-22 07:20:29,549 p=1435 u=gnalawad |  using connection plugin netconf
2017-08-22 07:20:30,023 p=1435 u=gnalawad |  network_os is set to junos
2017-08-22 07:20:30,024 p=1435 u=gnalawad |  ssh connection done, stating ncclient
2017-08-22 07:20:30,091 p=1435 u=gnalawad |  failed to create control socket for host vsrx01
2017-08-22 07:20:30,093 p=1435 u=gnalawad |  Traceback (most recent call last):
  File "/Users/gnalawad/ansible/ganeshrn/ansible/bin/ansible-connection", line 316, in main
    server = Server(socket_path, pc)
  File "/Users/gnalawad/ansible/ganeshrn/ansible/bin/ansible-connection", line 112, in __init__
    self.connection._connect()
  File "/Users/gnalawad/ansible/ganeshrn/ansible/lib/ansible/plugins/connection/netconf.py", line 107, in     _connect
    ssh_config=ssh_config
  File "/Library/Python/2.7/site-packages/ncclient/manager.py", line 154, in connect
    return connect_ssh(*args, **kwds)
  File "/Library/Python/2.7/site-packages/ncclient/manager.py", line 119, in connect_ssh
    session.connect(*args, **kwds)
  File "/Library/Python/2.7/site-packages/ncclient/transport/ssh.py", line 354, in connect
    config.parse(open(os.path.expanduser(ssh_config)))
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/posixpath.py", line 254, in    expanduser
    if not path.startswith('~'):
AttributeError: 'bool' object has no attribute 'startswith'

```



Discussion:

Resolving patch:
diff --git a/lib/ansible/plugins/connection/netconf.py b/lib/ansible/plugins/connection/netconf.py
--- a/lib/ansible/plugins/connection/netconf.py
+++ b/lib/ansible/plugins/connection/netconf.py
@@ -25,6 +25,7 @@
 from ansible import constants as C
 from ansible.errors import AnsibleConnectionFailure, AnsibleError
 from ansible.module_utils._text import to_bytes, to_native, to_text
+from ansible.module_utils.parsing.convert_bool import BOOLEANS_TRUE
 from ansible.plugins.loader import netconf_loader
 from ansible.plugins.connection import ConnectionBase, ensure_connect
 from ansible.utils.jsonrpc import Rpc
@@ -86,8 +87,10 @@ def _connect(self):
             raise AnsibleConnectionFailure('Unable to automatically determine host network os. Please ansible_network_os value')
 
         ssh_config = os.getenv('ANSIBLE_NETCONF_SSH_CONFIG', False)
-        if ssh_config == 'True':
+        if ssh_config in BOOLEANS_TRUE:
             ssh_config = True
+        else:
+            ssh_config = None
 
         try:
             self._manager = manager.connect(


Test patch: