def run(self, terms, variables=None, **kwargs):
ret = []
for term in terms:
'''
http://docs.python.org/2/library/subprocess.html#popen-constructor
The shell argument (which defaults to False) specifies whether to use the
shell as the program to execute. If shell is True, it is recommended to pass
args as a string rather than as a sequence
https://github.com/ansible/ansible/issues/6550
'''
name, params = _parse_parameters(term)
if params['regenerate']:
try:
generate_password(name, params['length'], params['symbols'], True)
display.vvv('Generated password for %s' % name)
except Exception as e:
raise AnsibleError("lookup_plugin.pass(%s) returned %s" % (term, e.message))
try:
password = get_password(term)
except:
try:
generate_password(name, params['length'], params['symbols'])
display.vvv('Generated password for %s' % name)
password = get_password(name)
except Exception as e:
raise AnsibleError("lookup_plugin.pass(%s) returned %s" % (term, e.message))
ret.append(password)
return ret
评论列表
文章目录