Skip to content

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

Open
@marcusphi

Description

@marcusphi

Affected versions

  • Puppet: 6.10
  • Module version: 3.0.0

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

  class {'::mongodb::server':
    storage_engine => 'wiredTiger',
    dbpath         => '/opt/mongodatafiles',
    dbpath_fix     => true,
    auth           => true,
    create_admin   => true,
    admin_username => 'admin',
    admin_password => 'secret123',
  }

Worth noting is that we have changed auth from false to true on an existing installation. I haven't tested a fresh installation with auth true. I have tested that the admin credentials still work after puppet run though.

After seeing https://forge.puppet.com/puppet/mongodb/readme#handle_creds I tried setting handle_creds => false but it didn't change anything. Do I really have to manage mongorc.js manually myself!?

Problem Description

Puppet log:

Error: Could not prefetch mongodb_database provider 'mongodb': Could not evaluate MongoDB shell command: rs.slaveOk();printjson(db.getMongo().getDBs())
Error: Failed to apply catalog: Could not evaluate MongoDB shell command: rs.slaveOk();printjson(db.getMongo().getDBs())

NB: This is even though we have no replicas and no mongodb_database or mongodb::db.

It seems here https://github.com/voxpupuli/puppet-mongodb/blob/v3.0.0/lib/puppet/provider/mongodb_database/mongodb.rb#L9 is where the call is made. I don't know Ruby well but I assume self.instances is invoked on some automatic instantiation even though we don't explicitly use it.

My guess is that #446 created this regression in combination with auth=true. It was noted by @Dharmender-Singh in the PR: #446 (comment) and I see no change in PR addressing this. But it seems weird that more people don't have this problem then...?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions