# mongodb\_document proposal

**URL:** <https://forum.ansible.com/t/mongodb-document-proposal/20031>\
**Category:** Ansible Developer\
**Created:** [December 16, 2015, 2:04pm UTC](https://forum.ansible.com/t/mongodb-document-proposal/20031 "2015-12-16T14:04:45Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kesten\_Broughton2](https://avatars.discourse-cdn.com/v4/letter/k/ecc23a/32.png) [@Kesten\_Broughton2](https://forum.ansible.com/u/Kesten_Broughton2)\
**Post date:** [December 16, 2015, 2:04pm UTC](https://forum.ansible.com/t/mongodb-document-proposal/20031/1 "2015-12-16T14:04:45Z")

</div>

Curious if anyone is working on other modules for mongodb.  
Currently there is mongodb\_user

I'd like to propose mongodb\_document to implement the following

EXAMPLES = '''  
# Create 'burger' document in 'menu' collection of 'restaurant' database.  
- mongodb\_document: database=burgers name=bob password=12345 state=present

# Create a document in an existing collection over SSL (MongoDB must be  
compiled with the SSL option and configured properly)  
- mongodb\_document:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;database: restaurant  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;collection: menu  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;document: burger  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;state: present  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ssl: True

# Delete 'menu' collection.  
- mongodb\_document:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;database: restaurant  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;collection: menu  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;state: absent

# Create database, collection and document  
- mongodb\_document:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;database: restaurant  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;collection: menu  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;document: burger  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;state: present

# Create document in repl1 replica set (it will automatically propagate to  
master)  
- mongodb\_document:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;database: restaurant  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;collection: menu  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;document: burger  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;replication\_set: repl1

# Create document only if it does not exist  
- mongodb\_document:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;database: restaurant  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;collection: menu  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;document: burger  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;force: False  
'''
