mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-05-21 16:39:08 -07:00
Add yaml support to passwordstore. (#1681)
Co-authored-by: Florian Bergmann <Florian.Bergmann@datev.de>
This commit is contained in:
parent
5a52b573fe
commit
f955a85848
3 changed files with 73 additions and 4 deletions
|
@ -105,6 +105,8 @@ _raw:
|
|||
import os
|
||||
import subprocess
|
||||
import time
|
||||
import yaml
|
||||
|
||||
|
||||
from distutils import util
|
||||
from ansible.errors import AnsibleError, AnsibleAssertionError
|
||||
|
@ -209,10 +211,15 @@ class LookupModule(LookupBase):
|
|||
).splitlines()
|
||||
self.password = self.passoutput[0]
|
||||
self.passdict = {}
|
||||
for line in self.passoutput[1:]:
|
||||
if ':' in line:
|
||||
name, value = line.split(':', 1)
|
||||
self.passdict[name.strip()] = value.strip()
|
||||
try:
|
||||
values = yaml.safe_load('\n'.join(self.passoutput[1:]))
|
||||
for key, item in values.items():
|
||||
self.passdict[key] = item
|
||||
except (yaml.YAMLError, AttributeError):
|
||||
for line in self.passoutput[1:]:
|
||||
if ':' in line:
|
||||
name, value = line.split(':', 1)
|
||||
self.passdict[name.strip()] = value.strip()
|
||||
except (subprocess.CalledProcessError) as e:
|
||||
if e.returncode != 0 and 'not in the password store' in e.output:
|
||||
# if pass returns 1 and return string contains 'is not in the password store.'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue