ansible-collections / community.mongodb

MongoDB Ansible Collection
http://galaxy.ansible.com/community/mongodb
GNU General Public License v3.0
108 stars 72 forks source link

error ”Unable to connect to database: Unknown option directConnection“ #581

Closed honey-wu closed 1 year ago

honey-wu commented 1 year ago

我在部署的时候报错:Unable to connect to database: Unknown option directConnection

我的代码:

rhysmeister commented 1 year ago

Looks like you're using an old version of the pymongo driver. Upgrade to a 4+ version.

honey-wu commented 1 year ago

看来您使用的是旧版本的 pymongo 驱动程序。升级到4+版本。

非常感谢您,将pymongo升级到4+版本后,就解决了这个问题。但我又遇到了个新的问题,您是否能帮我解答一下:我在部署mongodb分片集群添加shard的时候,报错提示No credentials to authenticate,但我在代码中使用了atlas_auth: true 参数,我的代码如下。

rhysmeister commented 1 year ago

Hello @Honey-Wu,

Did upgrading the driver solve the initial problem you reported?

"No credentials to authenticate" - Note the error. You should supply a username and password here. As I understand it, you cannot create Atlas instances without auth.

Cheers,

Rhys

honey-wu commented 1 year ago

你好@Honey-Wu,

升级驱动程序是否解决了您报告的最初问题?

“没有要验证的凭据” - 请注意错误。您应该在此处提供用户名和密码。据我了解,没有授权就无法创建 Atlas 实例。

干杯,

里斯

是的,升级驱动程序,我最初的那个问题就解决了

rhysmeister commented 1 year ago

No further feedback. Assuming all good. Closing.

mohag commented 4 months ago

Looks like you're using an old version of the pymongo driver. Upgrade to a 4+ version.

The documentation seems to imply that pymongo 2.4.2+ is supported.... (that link in there is broken as well, current version)

Requires the pymongo Python package on the remote host, version 2.4.2+. This can be installed using pip or the OS package manager. Newer mongo server versions require newer pymongo versions. @see http://api.mongodb.org/python/current/installation.html

With mongodb_role, I'm seeing the same error with Pymongo 3.10 (resulting in a "Unable to determine if auth is enabled")

This is due to this line (the check afterwards can also be removed with that line there, since that setting is forced in...) (I'm also not sure why is_auth_enabled is involved at all if I give credentials and anything other than replicaset creation is being done)

(I'm on the latest collection version (1.7.4) on an unsupported Ansible version (that won't affect this crash and I can't update Ansible on the Python version in Ubuntu 20.04), so it seems like I'll likely waste time and just get it closed.

This might mainly be a documentation issue - the docs might need an update to require pymongo 3.12+

Edit: check_compatibility checks for pymongo 4+ (which does not match the documentation) (but it likely only gets called after the crash in is_auth_enabled) (so I'm 99% sure the docs should say pymongo 4+)