##### SUMMARY
The `net_put` action plugin and likely other action plugins that use the `network_cli` connection plugin in the latest devel branch.

I tracked the problem to the following commit:

https://github.com/ansible/ansible/commit/7d3c4a88823846cbcea7c61de38658a6d63d4265

If I checkout the commit that immediately precedes this commit the module functions properly.

Note: This also impacts the following PR since I am using the same connection logic as `net_put`.

https://github.com/ansible/ansible/pull/60643

##### ISSUE TYPE
- Bug Report

##### COMPONENT NAME
network_cli plugin

##### ANSIBLE VERSION
```paste below
ansible 2.9.0.dev0
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/Users/mwiebe/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /Users/mwiebe/Projects/nxos_ansible/ansible_sanity_check/lib/ansible
  executable location = /Users/mwiebe/Projects/nxos_ansible/ansible_sanity_check/bin/ansible
  python version = 2.7.13 (default, Apr  4 2017, 08:47:57) [GCC 4.2.1 Compatible Apple LLVM 8.1.0 (clang-802.0.38)]
```

##### CONFIGURATION
```paste below
DEFAULT_ROLES_PATH(env: ANSIBLE_ROLES_PATH) = [u'/Users/mwiebe/Projects/nxos_ansible/ansible_sanity_check/test/integration/targets']
PARAMIKO_HOST_KEY_AUTO_ADD(env: ANSIBLE_PARAMIKO_HOST_KEY_AUTO_ADD) = True
PERSISTENT_COMMAND_TIMEOUT(env: ANSIBLE_PERSISTENT_COMMAND_TIMEOUT) = 1000
PERSISTENT_CONNECT_TIMEOUT(env: ANSIBLE_PERSISTENT_CONNECT_TIMEOUT) = 1000

```

##### OS / ENVIRONMENT
<!--- Provide all relevant information below, e.g. target OS versions, network device firmware, etc. -->


##### STEPS TO REPRODUCE

I am using the following playbook to demonstrate the problem and running it against an Nexus n9k device.

```yaml
  tasks:
    - name: copy file from ansible controller to a network device
      net_put:
        src: '/Users/mwiebe/Projects/nxos_ansible/fix_ansible/test/integration/network-integration.cfg' 
        dest: 'bootflash:'
```

I added a debug tracepoint inside `net_put` to display the problem:

Checkout commit that immediately precedes the problem commit:

```git
commit 7d3c4a88823846cbcea7c61de38658a6d63d4265 (HEAD)
Author: Nathaniel Case <ncase@redhat.com>
Date:   Wed Aug 14 16:58:03 2019 -0400

    Delay persistent connection until needed (#59153)
    
    * Delay calling connect() until absolutely necessary
    
    * Implement transport_test to enable wait_for_connection
    
    * plugin might be connected already for some reason?
    
    * ensure_connect for httpapi
    
    There's some become shenanigans still needing to be ironed out
    
    * Fix tests for network_cli

commit f02f5c4b5dad36d696f028078ab545d75ba93d31
Author: René Moser <mail@renemoser.net>
Date:   Wed Aug 14 22:55:31 2019 +0200

    cloudscale_server: add tags support (#60396)
``` 

```
git checkout f02f5c4b5dad36d696f028078ab545d75ba93d31
```

Add tracepoint and run the test:

```diff
diff --git a/lib/ansible/plugins/action/net_put.py b/lib/ansible/plugins/action/net_put.py
index bf6dd52d29..6506b7d11b 100644
--- a/lib/ansible/plugins/action/net_put.py
+++ b/lib/ansible/plugins/action/net_put.py
@@ -98,6 +98,7 @@ class ActionModule(ActionBase):
             socket_path = self._connection.socket_path
 
         conn = Connection(socket_path)
+        import epdb ; epdb.set_trace()
         sock_timeout = conn.get_option('persistent_command_timeout')
```

```diff
(Epdb) list
 97  	        if socket_path is None:
 98  	            socket_path = self._connection.socket_path
 99  	
100  	        conn = Connection(socket_path)
101  	        import epdb ; epdb.set_trace()
102  ->	        sock_timeout = conn.get_option('persistent_command_timeout')
103  	
104  	        if dest is None:
105  	            dest = src_file_path_name
106  	
107  	        try:
(Epdb) conn.exec_command('show version')
u'Cisco Nexus Operating System (NX-OS) Software\nTAC support: http://www.cisco.com/tac\nCopyright (C) 2002-2019, Cisco and/or its affiliates.\nAll rights reserved.\nThe copyrights to certain works contained in this software are\nowned by other third parties and used and distributed under their own\nlicenses, such as open source.  This software is provided "as is," and unless\notherwise stated, there is no warranty, express or implied, including but not\nlimited to warranties of merchantability and fitness for a particular purpose.\nCertain components of this software are licensed under\nthe GNU General Public License (GPL) version 2.0 or \nGNU General Public License (GPL) version 3.0  or the GNU\nLesser General Public License (LGPL) Version 2.1 or \nLesser General Public License (LGPL) Version 2.0. \nA copy of each such license is available at\nhttp://www.opensource.org/licenses/gpl-2.0.php and\nhttp://opensource.org/licenses/gpl-3.0.html and\nhttp://www.opensource.org/licenses/lgpl-2.1.php and\nhttp://www.gnu.org/licenses/old-licenses/library.txt.\n\nSoftware\n  BIOS: version 08.34\n NXOS: version 9.3(1) [build 9.2(1)IDI9(0.334)]\n  BIOS compile time:  04/26/2018\n  NXOS image file is: bootflash:///nxos.glmatthe.bin\n  NXOS compile time:  8/28/2019 17:00:00 [08/29/2019 18:32:39]\n\n\nHardware\n  cisco Nexus9000 C9504 (4 Slot) Chassis ("Supervisor Module")\n  Intel(R) Xeon(R) CPU E5-2403 0 @ 1.80GHz with 16399704 kB of memory.\n  Processor Board ID SAL1909A7VC\n\n  Device name: n9k-109\n  bootflash:   53298520 kB\nKernel uptime is 0 day(s), 0 hour(s), 8 minute(s), 30 second(s)\n\nLast reset at 165683 usecs after Thu Aug 29 19:03:48 2019\n  Reason: Reset Requested by CLI command reload\n  System version: 9.3(1)\n  Service: \n\nplugin\n  Core Plugin, Ethernet Plugin\n\nActive Package(s):'
(Epdb) 
```

As you can see it retrieves the version info properly.

Now, if I checkout 7d3c4a88823846cbcea7c61de38658a6d63d4265 I see the issue:

```
(Epdb) list
 97  	        if socket_path is None:
 98  	            socket_path = self._connection.socket_path
 99  	
100  	        conn = Connection(socket_path)
101  	        import epdb ; epdb.set_trace()
102  ->	        sock_timeout = conn.get_option('persistent_command_timeout')
103  	
104  	        if dest is None:
105  	            dest = src_file_path_name
106  	
107  	        try:
(Epdb) conn.exec_command('show version')
[127, u'', u'/bin/sh: show: command not found\n']
(Epdb) 
```

The exception behind this is:

```
"msg": "Exception received : 'NoneType' object has no attribute '_connect_uncached'"
```
if os.path.exists(source_file):
                    os.remove(source_file)
                return True
            else:
                try:
                    os.remove(source_file)
                except OSError as osex:
                    raise Exception(osex)
        try:
            with open(source, 'r') as f:
                new_content = f.read()
            with open(source_file, 'r') as f:
                old_content = f.read()
        except (IOError, OSError) as ioexc:
            os.remove(source_file)
            raise IOError(ioexc)
        sha1 = hashlib.sha1()
        old_content_b = to_bytes(old_content, errors='surrogate_or_strict')
        sha1.update(old_content_b)
        checksum_old = sha1.digest()
        sha1 = hashlib.sha1()
        new_content_b = to_bytes(new_content, errors='surrogate_or_strict')
        sha1.update(new_content_b)
        checksum_new = sha1.digest()
        os.remove(source_file)
        if checksum_old == checksum_new:
            return False
        else:
            return True
    def _get_binary_src_file(self, src):