|
|
@ -98,7 +98,7 @@ class LookupModule(LookupBase):
|
|
|
|
pathdir = os.path.dirname(path)
|
|
|
|
pathdir = os.path.dirname(path)
|
|
|
|
if not os.path.isdir(pathdir):
|
|
|
|
if not os.path.isdir(pathdir):
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
os.makedirs(pathdir, mode=0700)
|
|
|
|
os.makedirs(pathdir, mode=0o700)
|
|
|
|
except OSError as e:
|
|
|
|
except OSError as e:
|
|
|
|
raise AnsibleError("cannot create the path for the password lookup: %s (error was %s)" % (pathdir, str(e)))
|
|
|
|
raise AnsibleError("cannot create the path for the password lookup: %s (error was %s)" % (pathdir, str(e)))
|
|
|
|
|
|
|
|
|
|
|
@ -111,7 +111,7 @@ class LookupModule(LookupBase):
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
content = password
|
|
|
|
content = password
|
|
|
|
with open(path, 'w') as f:
|
|
|
|
with open(path, 'w') as f:
|
|
|
|
os.chmod(path, 0600)
|
|
|
|
os.chmod(path, 0o600)
|
|
|
|
f.write(content + '\n')
|
|
|
|
f.write(content + '\n')
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
content = open(path).read().rstrip()
|
|
|
|
content = open(path).read().rstrip()
|
|
|
@ -129,12 +129,12 @@ class LookupModule(LookupBase):
|
|
|
|
salt = self.random_salt()
|
|
|
|
salt = self.random_salt()
|
|
|
|
content = '%s salt=%s' % (password, salt)
|
|
|
|
content = '%s salt=%s' % (password, salt)
|
|
|
|
with open(path, 'w') as f:
|
|
|
|
with open(path, 'w') as f:
|
|
|
|
os.chmod(path, 0600)
|
|
|
|
os.chmod(path, 0o600)
|
|
|
|
f.write(content + '\n')
|
|
|
|
f.write(content + '\n')
|
|
|
|
# crypt not requested, remove salt if present
|
|
|
|
# crypt not requested, remove salt if present
|
|
|
|
elif (encrypt is None and salt):
|
|
|
|
elif (encrypt is None and salt):
|
|
|
|
with open(path, 'w') as f:
|
|
|
|
with open(path, 'w') as f:
|
|
|
|
os.chmod(path, 0600)
|
|
|
|
os.chmod(path, 0o600)
|
|
|
|
f.write(password + '\n')
|
|
|
|
f.write(password + '\n')
|
|
|
|
|
|
|
|
|
|
|
|
if encrypt:
|
|
|
|
if encrypt:
|
|
|
|