diff --git a/lib/ansible/modules/network/iosxr/iosxr_user.py b/lib/ansible/modules/network/iosxr/iosxr_user.py index 9e4b8356e8c..95f978a57df 100644 --- a/lib/ansible/modules/network/iosxr/iosxr_user.py +++ b/lib/ansible/modules/network/iosxr/iosxr_user.py @@ -216,11 +216,14 @@ try: except ImportError: HAS_B64 = False +HAS_PARAMIKO = True try: import paramiko - HAS_PARAMIKO = True except ImportError: - HAS_PARAMIKO = False + try: + import ansible_paramiko as paramiko + except ImportError: + HAS_PARAMIKO = False class PublicKeyManager(object): diff --git a/lib/ansible/modules/network/nxos/nxos_file_copy.py b/lib/ansible/modules/network/nxos/nxos_file_copy.py index 6dcffc2b522..8cd2fd2e376 100644 --- a/lib/ansible/modules/network/nxos/nxos_file_copy.py +++ b/lib/ansible/modules/network/nxos/nxos_file_copy.py @@ -165,11 +165,14 @@ from ansible.module_utils.network.nxos.nxos import nxos_argument_spec, check_arg from ansible.module_utils.basic import AnsibleModule from ansible.module_utils._text import to_native, to_text, to_bytes +HAS_PARAMIKO = True try: import paramiko - HAS_PARAMIKO = True except ImportError: - HAS_PARAMIKO = False + try: + import ansible_paramiko as paramiko + except ImportError: + HAS_PARAMIKO = False try: from scp import SCPClient diff --git a/lib/ansible/modules/network/panos/_panos_admpwd.py b/lib/ansible/modules/network/panos/_panos_admpwd.py index c6d0407b8f9..8bf85abd63e 100644 --- a/lib/ansible/modules/network/panos/_panos_admpwd.py +++ b/lib/ansible/modules/network/panos/_panos_admpwd.py @@ -86,11 +86,14 @@ from ansible.module_utils.basic import AnsibleModule import time import sys +HAS_LIB = True try: import paramiko - HAS_LIB = True except ImportError: - HAS_LIB = False + try: + import ansible_paramiko as paramiko + except ImportError: + HAS_LIB = False _PROMPTBUFF = 4096 diff --git a/lib/ansible/modules/network/panos/_panos_cert_gen_ssh.py b/lib/ansible/modules/network/panos/_panos_cert_gen_ssh.py index c15c155c045..990e861c5c0 100644 --- a/lib/ansible/modules/network/panos/_panos_cert_gen_ssh.py +++ b/lib/ansible/modules/network/panos/_panos_cert_gen_ssh.py @@ -91,11 +91,15 @@ from ansible.module_utils.basic import AnsibleModule from ansible.module_utils._text import to_native import time +HAS_LIB = True try: import paramiko - HAS_LIB = True except ImportError: - HAS_LIB = False + try: + import ansible_paramiko as paramiko + except ImportError: + HAS_LIB = False + _PROMPTBUFF = 4096 diff --git a/lib/ansible/plugins/connection/paramiko_ssh.py b/lib/ansible/plugins/connection/paramiko_ssh.py index 70a85ab0713..e590775ea96 100644 --- a/lib/ansible/plugins/connection/paramiko_ssh.py +++ b/lib/ansible/plugins/connection/paramiko_ssh.py @@ -176,7 +176,13 @@ with warnings.catch_warnings(): try: import paramiko HAVE_PARAMIKO = True - except (ImportError, AttributeError) as err: # paramiko and gssapi are incompatible and raise AttributeError not ImportError + except ImportError: + try: + import ansible_paramiko as paramiko + HAVE_PARAMIKO = True + except (ImportError, AttributeError) as err: # paramiko and gssapi are incompatible and raise AttributeError not ImportError + PARAMIKO_IMP_ERR = err + except AttributeError as err: # paramiko and gssapi are incompatible and raise AttributeError not ImportError PARAMIKO_IMP_ERR = err