Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support for pure yaml in mongodb.cfg #587

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

MaxFedotov
Copy link

Pull Request (PR) description

Support for pure yaml in /etc/mongodb.cfg.
Right now only records like net.bindIp are supported, and if for example, you are using custom configuration template and your configuration looks like:

net:
  port: 27017
  bindIp: 0.0.0.0

you will get an error like Error: Could not prefetch mongodb_database provider 'mongodb': Could not evaluate MongoDB shell command: load('/root/.mongorc.js'); rs.slaveOk();printjson(db.getMongo().getDBs()) when using providers.
This PR adds support for both configuration file formats

This Pull Request (PR) fixes the following issues

Fixes #562 for user @seidler2547

@vox-pupuli-tasks
Copy link

Dear @MaxFedotov, thanks for the PR!

This is Vox Pupuli Tasks, your friendly Vox Pupuli Github Bot. I noticed that your pull request has CI failures. Can you please have a look at the failing CI jobs?
If you need any help, you can reach out to us on our IRC channel voxpupuli on Freenode or our Slack channel voxpupuli at slack.puppet.com.
You can find my sourcecode at voxpupuli/vox-pupuli-tasks

@whiphubley
Copy link

whiphubley commented Jan 22, 2024

Please note this is still not fixed and the commit it issue 587 just attempts to handle the config file being in yaml. To clarify if you have auth enabled and have defined an admin user and password when you run puppet the following error occurs...

Error: Could not prefetch mongodb_database provider 'mongodb': Could not evaluate MongoDB shell command: load('/root/.mongorc.js'); try { rs.secondaryOk() } catch (err) { rs.slaveOk() };printjson(db.getMongo().getDBs()) Error: Failed to apply catalog: Could not evaluate MongoDB shell command: load('/root/.mongorc.js'); try { rs.secondaryOk() } catch (err) { rs.slaveOk() };printjson(db.getMongo().getDBs())

You have to disable auth and run puppet which is then able to create the admin user / db...

Notice: /Stage[main]/Mongodb::Server/Mongodb::Db[admin]/Mongodb_user[User admin on db admin]/ensure: created

And then you can finally re-enable authentication. There is clearly a race condition here which needs to be handled.

@stevenpost
Copy link
Contributor

@whiphubley
I have a PR waiting that fixes the race condition (and moves to mogosh): #703
Feel free to give that a try. I rebased this PR (the yaml stuff) on top of some patches I have laying around, but require the aforementioned PR, for those, see https://github.com/stevenpost/puppet-mongodb/tree/provider_cleanup.

@whiphubley
Copy link

@whiphubley I have a PR waiting that fixes the race condition (and moves to mogosh): #703 Feel free to give that a try. I rebased this PR (the yaml stuff) on top of some patches I have laying around, but require the aforementioned PR, for those, see https://github.com/stevenpost/puppet-mongodb/tree/provider_cleanup.

Thanks @stevenpost I'll take a look at this...tho probs after Easter now. But to get this working would be a big win so thanks.

@stevenpost
Copy link
Contributor

The 'race condition' is actually a dependency issue. Anyhow, the fix got merged into master. An updated version of this PR is now part of #723

@whiphubley
Copy link

Yes this is the last issue we really have with this module...so I look forward to testing it next week. Thanks again for all your work on this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error: "Could not evaluate MongoDB shell: rs.slaveOk();printjson(db.getMongo().getDBs())" when auth = true
4 participants