From 165406cf3563c509972150f834ecd6d94852a799 Mon Sep 17 00:00:00 2001 From: BoscoMW Date: Wed, 2 Apr 2014 13:42:07 +0300 Subject: [PATCH 1/2] Catch permissions errors related to opening a known_hosts file Catch permissions errors related to opening a known_hosts file --- lib/ansible/runner/connection_plugins/ssh.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/ansible/runner/connection_plugins/ssh.py b/lib/ansible/runner/connection_plugins/ssh.py index 876f206384..2c2261194c 100644 --- a/lib/ansible/runner/connection_plugins/ssh.py +++ b/lib/ansible/runner/connection_plugins/ssh.py @@ -207,9 +207,15 @@ class Connection(object): if not os.path.exists(hf): hfiles_not_found += 1 continue - host_fh = open(hf) - data = host_fh.read() - host_fh.close() + try: + host_fh = open(hf) + except IOError, e: + hfiles_not_found += 1 + continue + else + data = host_fh.read() + host_fh.close() + for line in data.split("\n"): if line is None or " " not in line: continue From 39fcbd1f10a0f4cfb1a29a70912bc724ca9cea32 Mon Sep 17 00:00:00 2001 From: BoscoMW Date: Wed, 2 Apr 2014 15:57:54 +0300 Subject: [PATCH 2/2] Update ssh.py --- lib/ansible/runner/connection_plugins/ssh.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ansible/runner/connection_plugins/ssh.py b/lib/ansible/runner/connection_plugins/ssh.py index 2c2261194c..8bf927f4d8 100644 --- a/lib/ansible/runner/connection_plugins/ssh.py +++ b/lib/ansible/runner/connection_plugins/ssh.py @@ -212,7 +212,7 @@ class Connection(object): except IOError, e: hfiles_not_found += 1 continue - else + else: data = host_fh.read() host_fh.close()