From eae89425834dea0a5bec865d5a64e48a7d5d81b3 Mon Sep 17 00:00:00 2001 From: Brian Coca Date: Mon, 2 Nov 2015 21:49:46 -0500 Subject: [PATCH] avoid index error on empty list, key being true means its not None nor [] fixes #13009 --- lib/ansible/modules/extras/system/known_hosts.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/ansible/modules/extras/system/known_hosts.py b/lib/ansible/modules/extras/system/known_hosts.py index 7592574d4e..b68e85e0e7 100644 --- a/lib/ansible/modules/extras/system/known_hosts.py +++ b/lib/ansible/modules/extras/system/known_hosts.py @@ -92,8 +92,8 @@ def enforce_state(module, params): #Find the ssh-keygen binary sshkeygen = module.get_bin_path("ssh-keygen",True) - #trailing newline in files gets lost, so re-add if necessary - if key is not None and key[-1]!='\n': + # Trailing newline in files gets lost, so re-add if necessary + if key and key[-1] != '\n': key+='\n' if key is None and state != "absent":