From 8c521655e1bf45aa95b07d2372e7beaf1cef9d1f Mon Sep 17 00:00:00 2001 From: jctanner Date: Wed, 22 Feb 2017 16:14:39 -0500 Subject: [PATCH] Fix traceback on indexing empty list (#21784) * Fix traceback on indexing empty list * Make it more 'idiomatic' * Forgot the index --- lib/ansible/plugins/action/__init__.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/ansible/plugins/action/__init__.py b/lib/ansible/plugins/action/__init__.py index 8f920fb573f..4f161a3f64e 100644 --- a/lib/ansible/plugins/action/__init__.py +++ b/lib/ansible/plugins/action/__init__.py @@ -543,7 +543,10 @@ class ActionBase(with_metaclass(ABCMeta, object)): cmd = self._connection._shell.expand_user(expand_path) data = self._low_level_execute_command(cmd, sudoable=False) - initial_fragment = data['stdout'].strip().splitlines()[-1] + try: + initial_fragment = data['stdout'].strip().splitlines()[-1] + except IndexError: + initial_fragment = None if not initial_fragment: # Something went wrong trying to expand the path remotely. Return