pass.py 文件源码

python
阅读 31 收藏 0 点赞 0 评论 0

项目:ansible-lookup-plugin-pass 作者: gcoop-libre 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号