mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Fixes #6482 Check sysctl file path and catch read exceptions
This commit is contained in:
parent
b2350d8aaf
commit
9d6518de5a
1 changed files with 10 additions and 1 deletions
|
@ -235,7 +235,16 @@ class SysctlModule(object):
|
|||
|
||||
# Get the token value from the sysctl file
|
||||
def read_sysctl_file(self):
|
||||
lines = open(self.sysctl_file, "r").readlines()
|
||||
|
||||
lines = []
|
||||
if os.path.isfile(self.sysctl_file):
|
||||
try:
|
||||
f = open(self.sysctl_file, "r")
|
||||
lines = f.readlines()
|
||||
f.close()
|
||||
except IOError, e:
|
||||
self.module.fail_json(msg="Failed to open %s: %s" % (self.sysctl_file, str(e)))
|
||||
|
||||
for line in lines:
|
||||
line = line.strip()
|
||||
self.file_lines.append(line)
|
||||
|
|
Loading…
Reference in a new issue