voxpupuli / puppet-mongodb

mongodb installation
Apache License 2.0
92 stars 451 forks source link

removed mongo cli in 6.0 is not compatible with outputs from new mongosh #648

Closed tsgoff closed 7 months ago

tsgoff commented 2 years ago

Affected Puppet, Ruby, OS and module versions/distributions

How to reproduce (e.g Puppet code you use)

  class { '::mongodb::globals':
    manage_package_repo => true,
    version             => '6.0.0',
  }

What are you seeing

Error: /Stage[main]/Mongodb::Replset/Mongodb_replset[mongodb.int]: Could not evaluate: Can't connect to any member of replicaset mongodb.int.
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())

mongodb_version.rb: mongodb_version = Facter::Core::Execution.execute('mongo --version 2>&1') is_master.rb: Facter::Core::Execution.exec("mongo --quiet #{options} --eval \"#{e}printjson(db.adminCommand({ ping: 1 }))\"")

replset_spec.rb: on hosts_as('slave'), %{mongo test --verbose --eval 'load("/root/.mongorc.js");try { rs.secondaryOk() } catch (err) { rs.slaveOk() };printjson(db.dummyData.findOne())'}

What behaviour did you expect instead

Output log

Any additional information you'd like to impart

The old mongo cli is used in the ruby scripts to configure the mongo db. The outputs of mongosh are not compatible with the expected outputs. What would be the suggested way to adjust this? Rework all scripts to work with mongosh output and implement a condition for version > 5.0.9?

ghost commented 1 year ago
  1. mongo cli renamed to mongosh, provider should call this binary (workaround: ln -s mongosh /usr/bin/mongo )
  2. rs.secondaryOk() calls, return: DeprecationWarning: .setSecondaryOk() is deprecated. Use .setReadPref("primaryPreferred") instead fix (?): use db.getMongo().setReadPref("secondaryPreferred")
tsgoff commented 1 year ago
  1. mongo cli renamed to mongosh, provider should call this binary (workaround: ln -s mongosh /usr/bin/mongo )
  2. rs.secondaryOk() calls, return: DeprecationWarning: .setSecondaryOk() is deprecated. Use .setReadPref("primaryPreferred") instead fix (?): use db.getMongo().setReadPref("secondaryPreferred")

In version 5 are both mongo cli and mongosh installed. In version 6 you cannot install mongo cli. A symlink does not work because the output is different.

pbsladek commented 1 year ago

ln -s mongosh /usr/bin/mongo kinda works for me on 6. Also symlink the mongosh config. So i can get around the errors above.. but it leads to new errors.

While the db can be finally configured via cmdline to work around the module issues.. puppet won't run at least for replset.

Error: Could not prefetch mongodb_replset provider 'mongo': 765: unexpected token at '{
  _id: 'rsxxx',
  version: 5,
  term: 1,
  members: [
    {

Would love to get some module updates to support mongosh and 6.X out of the box.

witjoh commented 1 year ago

https://github.com/voxpupuli/puppet-mongodb/pull/677 This PR only uses mongosh, and works on redhat for now for mongodb 6.x version. Still work in process.