mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Clearer error logging in passwordstore lookup (#5436)
* Clearer error logging in passwordstore lookup * Add changelog fragment for passwordstore errmsgs Co-authored-by: Sylvia van Os <sylvia@hackerchick.me>
This commit is contained in:
parent
5fe0f57033
commit
e4b9e098c7
2 changed files with 6 additions and 4 deletions
2
changelogs/fragments/5436-passwordstore-errors.yml
Normal file
2
changelogs/fragments/5436-passwordstore-errors.yml
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
minor_changes:
|
||||||
|
- passwordstore lookup plugin - improve error messages to include stderr (https://github.com/ansible-collections/community.general/pull/5436)
|
|
@ -268,7 +268,7 @@ class LookupModule(LookupBase):
|
||||||
)
|
)
|
||||||
self.realpass = 'pass: the standard unix password manager' in passoutput
|
self.realpass = 'pass: the standard unix password manager' in passoutput
|
||||||
except (subprocess.CalledProcessError) as e:
|
except (subprocess.CalledProcessError) as e:
|
||||||
raise AnsibleError(e)
|
raise AnsibleError('exit code {0} while running {1}. Error output: {2}'.format(e.returncode, e.cmd, e.output))
|
||||||
|
|
||||||
return self.realpass
|
return self.realpass
|
||||||
|
|
||||||
|
@ -354,7 +354,7 @@ class LookupModule(LookupBase):
|
||||||
except (subprocess.CalledProcessError) as e:
|
except (subprocess.CalledProcessError) as e:
|
||||||
# 'not in password store' is the expected error if a password wasn't found
|
# 'not in password store' is the expected error if a password wasn't found
|
||||||
if 'not in the password store' not in e.output:
|
if 'not in the password store' not in e.output:
|
||||||
raise AnsibleError(e)
|
raise AnsibleError('exit code {0} while running {1}. Error output: {2}'.format(e.returncode, e.cmd, e.output))
|
||||||
|
|
||||||
if self.paramvals['missing'] == 'error':
|
if self.paramvals['missing'] == 'error':
|
||||||
raise AnsibleError('passwordstore: passname {0} not found and missing=error is set'.format(self.passname))
|
raise AnsibleError('passwordstore: passname {0} not found and missing=error is set'.format(self.passname))
|
||||||
|
@ -387,7 +387,7 @@ class LookupModule(LookupBase):
|
||||||
try:
|
try:
|
||||||
check_output2([self.pass_cmd, 'insert', '-f', '-m', self.passname], input=msg, env=self.env)
|
check_output2([self.pass_cmd, 'insert', '-f', '-m', self.passname], input=msg, env=self.env)
|
||||||
except (subprocess.CalledProcessError) as e:
|
except (subprocess.CalledProcessError) as e:
|
||||||
raise AnsibleError(e)
|
raise AnsibleError('exit code {0} while running {1}. Error output: {2}'.format(e.returncode, e.cmd, e.output))
|
||||||
return newpass
|
return newpass
|
||||||
|
|
||||||
def generate_password(self):
|
def generate_password(self):
|
||||||
|
@ -399,7 +399,7 @@ class LookupModule(LookupBase):
|
||||||
try:
|
try:
|
||||||
check_output2([self.pass_cmd, 'insert', '-f', '-m', self.passname], input=msg, env=self.env)
|
check_output2([self.pass_cmd, 'insert', '-f', '-m', self.passname], input=msg, env=self.env)
|
||||||
except (subprocess.CalledProcessError) as e:
|
except (subprocess.CalledProcessError) as e:
|
||||||
raise AnsibleError(e)
|
raise AnsibleError('exit code {0} while running {1}. Error output: {2}'.format(e.returncode, e.cmd, e.output))
|
||||||
return newpass
|
return newpass
|
||||||
|
|
||||||
def get_passresult(self):
|
def get_passresult(self):
|
||||||
|
|
Loading…
Reference in a new issue