Module to provide MongoDB functionality to Salt
configuration: |
This module uses PyMongo, and accepts configuration details as parameters as well as configuration settings: mongodb.host: 'localhost' mongodb.port: 27017 mongodb.user: '' mongodb.password: '' This data can also be passed into pillar. Options passed into opts will overwrite options passed into pillar. |
---|
Checks if a database exists in MongoDB
CLI Example:
salt '*' mongodb.db_exists <name> <user> <password> <host> <port>
List all MongoDB databases
CLI Example:
salt '*' mongodb.db_list <user> <password> <host> <port>
Remove a MongoDB database
CLI Example:
salt '*' mongodb.db_remove <name> <user> <password> <host> <port>
Find an object or list of objects in a collection
CLI Example:
salt '*' mongodb.find mycollection '[{"foo": "FOO", "bar": "BAR"}]' <user> <password> <host> <port> <database>
Insert an object or list of objects into a collection
CLI Example:
salt '*' mongodb.insert '[{"foo": "FOO", "bar": "BAR"}, {"foo": "BAZ", "bar": "BAM"}]' mycollection <user> <password> <host> <port> <database>
Remove an object or list of objects into a collection
CLI Example:
salt '*' mongodb.remove mycollection '[{"foo": "FOO", "bar": "BAR"}, {"foo": "BAZ", "bar": "BAM"}]' <user> <password> <host> <port> <database>
Update an object into a collection http://api.mongodb.com/python/current/api/pymongo/collection.html#pymongo.collection.Collection.update_one
New in version 2016.11.0.
CLI Example:
salt '*' mongodb.update_one '{"_id": "my_minion"} {"bar": "BAR"}' mycollection <user> <password> <host> <port> <database>
Create a MongoDB user
CLI Example:
salt '*' mongodb.user_create <user_name> <user_password> <roles> <user> <password> <host> <port> <database>
Checks if a user exists in MongoDB
CLI Example:
salt '*' mongodb.user_exists <name> <user> <password> <host> <port> <database>
Get single user from MongoDB
CLI Example:
salt '*' mongodb.user_find <name> <user> <password> <host> <port> <database> <authdb>
Grant one or many roles to a MongoDB user
CLI Examples:
salt '*' mongodb.user_grant_roles johndoe '["readWrite"]' dbname admin adminpwd localhost 27017
salt '*' mongodb.user_grant_roles janedoe '[{"role": "readWrite", "db": "dbname" }, {"role": "read", "db": "otherdb"}]' dbname admin adminpwd localhost 27017
List users of a MongoDB database
CLI Example:
salt '*' mongodb.user_list <user> <password> <host> <port> <database>
Remove a MongoDB user
CLI Example:
salt '*' mongodb.user_remove <name> <user> <password> <host> <port> <database>
Revoke one or many roles to a MongoDB user
CLI Examples:
salt '*' mongodb.user_revoke_roles johndoe '["readWrite"]' dbname admin adminpwd localhost 27017
salt '*' mongodb.user_revoke_roles janedoe '[{"role": "readWrite", "db": "dbname" }, {"role": "read", "db": "otherdb"}]' dbname admin adminpwd localhost 27017
Checks if a user of a MongoDB database has specified roles
CLI Examples:
salt '*' mongodb.user_roles_exists johndoe '["readWrite"]' dbname admin adminpwd localhost 27017
salt '*' mongodb.user_roles_exists johndoe '[{"role": "readWrite", "db": "dbname" }, {"role": "read", "db": "otherdb"}]' dbname admin adminpwd localhost 27017
Get MongoDB instance version
CLI Example:
salt '*' mongodb.version <user> <password> <host> <port> <database>
© 2019 SaltStack.
Licensed under the Apache License, Version 2.0.
https://docs.saltstack.com/en/latest/ref/modules/all/salt.modules.mongodb.html