From 9f830b77fccb79dcca85ab8803caf19f73134d57 Mon Sep 17 00:00:00 2001 From: Mike Wiebe Date: Thu, 2 May 2019 08:36:25 -0400 Subject: [PATCH] Fix passwordless workflow (#55441) --- lib/ansible/modules/network/nxos/nxos_file_copy.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/ansible/modules/network/nxos/nxos_file_copy.py b/lib/ansible/modules/network/nxos/nxos_file_copy.py index c1f6bbaca98..07a5943418f 100644 --- a/lib/ansible/modules/network/nxos/nxos_file_copy.py +++ b/lib/ansible/modules/network/nxos/nxos_file_copy.py @@ -288,12 +288,13 @@ def copy_file_from_remote(module, local, local_file_directory, file_system='boot try: child = pexpect.spawn('ssh ' + username + '@' + hostname + ' -p' + str(port)) # response could be unknown host addition or Password - index = child.expect(['yes', '(?i)Password']) + index = child.expect(['yes', '(?i)Password', '#']) if index == 0: child.sendline('yes') child.expect('(?i)Password') - child.sendline(password) - child.expect('#') + if index == 1: + child.sendline(password) + child.expect('#') ldir = '/' if local_file_directory: dir_array = local_file_directory.split('/')