voxpupuli / puppet-mongodb

mongodb installation

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

puppet-mongodb module doesn't show Mongo shell errors in puppet-agent run

makhovaa opened this issue · comments

Affected Puppet, Ruby, OS and module versions/distributions

  • Puppet: 6.20.0-1stretch
  • Ruby: 2.3.3
  • Distribution: Debian11
  • Module version: 6.28.0-1buster

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

Create a new database. Hiera code:

tele2_mongodb::mongodb_db:
  'unixtest_db':  # DB name
    user     : unixtest
    password : >
      ENC[PKCS7,....]  
    auth_mechanism : scram_sha_1
    roles    :
      - dbOwner

Run puppet-agent on the client side. There is a notification in the agent output:
Notice: /Stage[main]/Tele2_mongodb/Mongodb::Db[unixtest_db]/Mongodb_database[unixtest_db]/ensure: created
Check list of databases:

PRIMARY> show dbs
admin         0.000GB
config        0.000GB
local         0.017GB
unixtest_db   0.000GB

Change DB name to all capital letters:

tele2_mongodb::mongodb_db:
  'UNIXTEST_DB':  # DB name
    user     : unixtest
    etc...

Run puppet-agent ton the client again. See in the agent output:
Notice: /Stage[main]/Tele2_mongodb/Mongodb::Db[UNIXTEST_DB]/Mongodb_database[UNIXTEST_DB]/ensure: created
So the module reported the DB with all capital laters is created.
Check list of DBs:

PRIMARY> show dbs
admin         0.000GB
config        0.000GB
local         0.017GB
unixtest_db   0.000GB

What are you seeing

The puppet run doesn't report any errors and just send the notification the DB with the new name is created.
In the same time the list of DBs doesn't have any changes.

What behavior did you expect instead

Error "db already exists with different case already have: [unixtest_db] trying to create [UNIXTEST_DB]"
or at least any massage the operation went wrong.

Output log

In the puppet agent debug mode we see the command which are executing during the puppet run.
Debug: Executing: '/usr/bin/mongo UNIXTEST_DB --quiet --host 127.0.0.1:27017 --eval load('/root/.mongorc.js'); db.dummyData.insert({"created_by_puppet": 1})'

If we make a Linux terminal command based on command running in puppet and run it in the terminal, we see:

# /usr/bin/mongo UNIXTEST_DB  --host 127.0.0.1:27017 --eval " load('/root/.mongorc.js'); db.dummyData.insert({"created_by_puppet": 1})"                                                     
MongoDB shell version v5.0.9
connecting to: mongodb://127.0.0.1:27017/UNIXTEST_DB?compressors=disabled&gssapiServiceName=mongodb
Implicit session: session { "id" : UUID("38f99799-d656-4483-b39a-a17f2c743d37") }
MongoDB server version: 5.0.9
WriteResult({
        "nInserted" : 0,
        "writeError" : {
                "code" : 13297,
                "errmsg" : "db already exists with different case already have: [unixtest_db] trying to create [UNIXTEST_DB]"                                                                                      
        }
})

So the command result is the error, but we just don't see it in the output.

Any additional information you'd like to impart

I have the same problem for DB changes, users and passwords. If something went wrong we never know that from the puppet output.

@makhovaa we merged #663, does that fix your problem?