bebat_mongodb_user.py 文件源码

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

项目:Ansible-MongoDB-Install-Role 作者: bbatsche 项目源码 文件源码
def __init__(self, module):
        self.module = module

        self.login_user     = module.params['login_user']
        self.login_password = module.params['login_password']
        self.login_host     = module.params['login_host']
        self.login_port     = int(module.params['login_port'])
        self.login_database = module.params['login_database']

        self.replica_set = module.params['replica_set']
        self.ssl         = module.params['ssl']

        self.database = module.params['database']

        self.client = self.get_client()

        if self.login_user is None and self.login_password is None:
            if not self.load_mongocnf() and LooseVersion(PyMongoVersion) >= LooseVersion('3.0') and self.database != "admin":
               module.fail_json(msg='The localhost login exception only allows the first admin account to be created')
        elif self.login_password is None or self.login_user is None:
            module.fail_json(msg='when supplying login arguments, both login_user and login_password must be provided')

        if not self.localhost_exception():
            self.client.admin.authenticate(self.login_user, self.login_password, source=self.login_database)

        self.check_compatibility()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号