mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-28 13:21:25 -07:00
Python 2.6 str.format()
compatibility fixes.
This commit is contained in:
parent
95ff8f1a90
commit
797664d9cb
20 changed files with 43 additions and 62 deletions
|
@ -154,14 +154,14 @@ class LookupModule(LookupBase):
|
|||
if self.paramvals['length'].isdigit():
|
||||
self.paramvals['length'] = int(self.paramvals['length'])
|
||||
else:
|
||||
raise AnsibleError("{} is not a correct value for length".format(self.paramvals['length']))
|
||||
raise AnsibleError("{0} is not a correct value for length".format(self.paramvals['length']))
|
||||
|
||||
# Set PASSWORD_STORE_DIR if directory is set
|
||||
if self.paramvals['directory']:
|
||||
if os.path.isdir(self.paramvals['directory']):
|
||||
os.environ['PASSWORD_STORE_DIR'] = self.paramvals['directory']
|
||||
else:
|
||||
raise AnsibleError('Passwordstore directory \'{}\' does not exist'.format(self.paramvals['directory']))
|
||||
raise AnsibleError('Passwordstore directory \'{0}\' does not exist'.format(self.paramvals['directory']))
|
||||
|
||||
def check_pass(self):
|
||||
try:
|
||||
|
@ -180,7 +180,7 @@ class LookupModule(LookupBase):
|
|||
# if pass returns 1 and return string contains 'is not in the password store.'
|
||||
# We need to determine if this is valid or Error.
|
||||
if not self.paramvals['create']:
|
||||
raise AnsibleError('passname: {} not found, use create=True'.format(self.passname))
|
||||
raise AnsibleError('passname: {0} not found, use create=True'.format(self.passname))
|
||||
else:
|
||||
return False
|
||||
else:
|
||||
|
@ -199,7 +199,7 @@ class LookupModule(LookupBase):
|
|||
newpass = self.get_newpass()
|
||||
datetime = time.strftime("%d/%m/%Y %H:%M:%S")
|
||||
msg = newpass + '\n' + '\n'.join(self.passoutput[1:])
|
||||
msg += "\nlookup_pass: old password was {} (Updated on {})\n".format(self.password, datetime)
|
||||
msg += "\nlookup_pass: old password was {0} (Updated on {1})\n".format(self.password, datetime)
|
||||
try:
|
||||
check_output2(['pass', 'insert', '-f', '-m', self.passname], input=msg)
|
||||
except (subprocess.CalledProcessError) as e:
|
||||
|
@ -211,7 +211,7 @@ class LookupModule(LookupBase):
|
|||
# use pwgen to generate the password and insert values with pass -m
|
||||
newpass = self.get_newpass()
|
||||
datetime = time.strftime("%d/%m/%Y %H:%M:%S")
|
||||
msg = newpass + '\n' + "lookup_pass: First generated by ansible on {}\n".format(datetime)
|
||||
msg = newpass + '\n' + "lookup_pass: First generated by ansible on {0}\n".format(datetime)
|
||||
try:
|
||||
check_output2(['pass', 'insert', '-f', '-m', self.passname], input=msg)
|
||||
except (subprocess.CalledProcessError) as e:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue