mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-23 13:20:23 -07:00
Catch permissions errors related to opening a known_hosts file in modules
Fixes #6644
This commit is contained in:
parent
dc658eaa1c
commit
bc93732b1d
1 changed files with 10 additions and 3 deletions
|
@ -87,9 +87,16 @@ def not_in_host_file(self, host):
|
||||||
if not os.path.exists(hf):
|
if not os.path.exists(hf):
|
||||||
hfiles_not_found += 1
|
hfiles_not_found += 1
|
||||||
continue
|
continue
|
||||||
host_fh = open(hf)
|
|
||||||
data = host_fh.read()
|
try:
|
||||||
host_fh.close()
|
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"):
|
for line in data.split("\n"):
|
||||||
if line is None or line.find(" ") == -1:
|
if line is None or line.find(" ") == -1:
|
||||||
continue
|
continue
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue