You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Description
Using MongoDB for tops and pillars is currently broken, due to differences in how they connect to the database.
pillar/mongo.py can use mongo.uri, but throws an exception if mongo.host is also provided
tops/mongo.py ignores mongo.uri, so it is required to provide all the mongo.* options
none of the above provides an authSource parameter, so pymongo defaults to admin, resulting in authentication failures if the DB user has been created in the salt DB.
modules/mongodb.py provides a method for connecting, but that's not used
in general, the code for connecting to the DB looks quite different in pillar/mongo.py and tops/mongo.py
ext_pillar:
- ...
- mongo: {collection: pillar}
...
master_tops:
mongo:
collection: tops
id_field: _id
states_field: states
environment_field: environment
mongo.db: salt
mongo.host: localhost
mongo.indexes: true
mongo.password: Secret
mongo.user: salt
Please be as specific as possible and give set-up details.
on-prem machine
VM (Virtualbox, KVM, etc. please specify)
VM running on a cloud service, please be explicit and add details
container (Kubernetes, Docker, containerd, etc. please specify)
or a combination, please be explicit
jails if it is FreeBSD
classic packaging
onedir packaging
used bootstrap to install
Steps to Reproduce the behavior
Install/update Salt master to 3006.7 using onedir packages on Ubuntu Jammy
Install pymongo==3.13.0 using Salts internal Python/pip
Expected behavior
Pillars/Tops in MongoDB work as before
Versions Report
salt --versions-report
(Provided by running salt --versions-report. Please also mention any differences in master/minion versions.)
Salt Version:
Salt: 3006.7Python Version:
Python: 3.10.13 (main, Feb 19 2024, 03:34:22) [GCC 11.2.0]Dependency Versions:
cffi: 1.14.6cherrypy: unknowndateutil: 2.8.1docker-py: Not Installedgitdb: 4.0.11gitpython: 3.1.42Jinja2: 3.1.3libgit2: Not Installedlooseversion: 1.0.2M2Crypto: Not InstalledMako: Not Installedmsgpack: 1.0.2msgpack-pure: Not Installedmysql-python: Not Installedpackaging: 22.0pycparser: 2.21pycrypto: 3.20.0pycryptodome: 3.19.1pygit2: Not Installedpython-gnupg: 2.3.1PyYAML: 6.0.1PyZMQ: 23.2.0relenv: 0.15.1smmap: 5.0.1timelib: 0.2.4Tornado: 4.5.3ZMQ: 4.3.4System Versions:
dist: ubuntu 20.04.2 jammylocale: utf-8machine: aarch64release: 6.2.0-1018-awssystem: Linuxversion: Ubuntu 20.04.2 jammy
Additional context
I have fixed/worked around point 3 above by adding an authSource=db parameter to pymongo.MongoClient() in both pillar/mongo.py and tops/mongo.py. However, this is not as clean as it could be.
The text was updated successfully, but these errors were encountered:
Additional context I have fixed/worked around point 3 above by adding an authSource=db parameter to pymongo.MongoClient() in both pillar/mongo.py and tops/mongo.py. However, this is not as clean as it could be.
I am currently trying to implement a similar patch in my project; would be willing to provide an example of what you had to do to get it working? I've been poking at the files but I'm getting an error.
I manually rolled back to earlier than the version identified and it's working. So please ignore; and sorry for the spam emails.
Description
Using MongoDB for tops and pillars is currently broken, due to differences in how they connect to the database.
pillar/mongo.py
can usemongo.uri
, but throws an exception ifmongo.host
is also providedtops/mongo.py
ignoresmongo.uri
, so it is required to provide all themongo.*
optionsauthSource
parameter, sopymongo
defaults toadmin
, resulting in authentication failures if the DB user has been created in thesalt
DB.modules/mongodb.py
provides a method for connecting, but that's not usedpillar/mongo.py
andtops/mongo.py
pymongo
versions (Hint: Versions >= 3.13.0 don't work)Setup
Please be as specific as possible and give set-up details.
Steps to Reproduce the behavior
pymongo==3.13.0
using Salts internal Python/pipExpected behavior
Pillars/Tops in MongoDB work as before
Versions Report
salt --versions-report
(Provided by running salt --versions-report. Please also mention any differences in master/minion versions.)Additional context
I have fixed/worked around point 3 above by adding an
authSource=db
parameter topymongo.MongoClient()
in bothpillar/mongo.py
andtops/mongo.py
. However, this is not as clean as it could be.The text was updated successfully, but these errors were encountered: