New in version 2.3.
MongoDB
lookup runs the find() command on a given collection on a given MongoDB server.The below requirements are needed on the local master node that executes this lookup.
Parameter |
Choices/Defaults |
Configuration |
Comments |
---|---|---|---|
collection
required |
|
|
Name of the collection which the query will be made
|
connect_string
|
Default:
mongodb://localhost/
|
|
Can be any valid MongoDB connection string, supporting authentication, replicasets, etc.
|
database
required |
|
|
Name of the database which the query will be made
|
filter
|
Default:
{}
|
|
Criteria of the output
|
limit
|
|
|
How many results should be shown
|
projection
|
Default:
{}
|
|
Fields you want returned
|
skip
|
|
|
How many results should be skept
|
sort
|
Default:
[]
|
|
Sorting rules. Please notice the constats are replaced by strings.
|
Note
- hosts: all
gather_facts: false
vars:
mongodb_parameters:
#mandatory parameters
database: 'local'
#optional
collection: "startup_log"
connection_string: "mongodb://localhost/"
extra_connection_parameters: { "ssl" : True , "ssl_certfile": /etc/self_signed_certificate.pem" }
#optional query parameters, we accept any parameter from the normal mongodb query.
filter: { "hostname": "batman" }
projection: { "pid": True , "_id" : False , "hostname" : True }
skip: 0
limit: 1
sort: [ [ "startTime" , "ASCENDING" ] , [ "age", "DESCENDING" ] ]
tasks:
- debug: msg="Mongo has already started with the following PID [{{ item.pid }}]"
with_mongodb: "{{mongodb_parameters}}"
Hint
If you notice any issues in this documentation you can edit this document to improve it.