From 0b3ed626b3157d4dd00b7368acb8fe0d69ac94ec Mon Sep 17 00:00:00 2001 From: vigiroux Date: Tue, 15 May 2018 18:26:53 -0400 Subject: [PATCH] empty lines in csvfile means row has no items in list; check row len first. (#40089) --- lib/ansible/plugins/lookup/csvfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ansible/plugins/lookup/csvfile.py b/lib/ansible/plugins/lookup/csvfile.py index 82e1b842ea0..8e7a03590ae 100644 --- a/lib/ansible/plugins/lookup/csvfile.py +++ b/lib/ansible/plugins/lookup/csvfile.py @@ -106,7 +106,7 @@ class LookupModule(LookupBase): creader = CSVReader(f, delimiter=to_native(delimiter), encoding=encoding) for row in creader: - if row[0] == key: + if len(row) and row[0] == key: return row[int(col)] except Exception as e: raise AnsibleError("csvfile: %s" % to_native(e))