salt.tops.mongo

Read tops data from a mongodb collection

This module will load tops data from a mongo collection. It uses the node's id for lookups.

Salt Master Mongo Configuration

The module shares the same base mongo connection variables as salt.returners.mongo_return. These variables go in your master config file.

  • mongo.db - The mongo database to connect to. Defaults to 'salt'.
  • mongo.host - The mongo host to connect to. Supports replica sets by specifying all hosts in the set, comma-delimited. Defaults to 'salt'.
  • mongo.port - The port that the mongo database is running on. Defaults to 27017.
  • mongo.user - The username for connecting to mongo. Only required if you are using mongo authentication. Defaults to ''.
  • mongo.password - The password for connecting to mongo. Only required if you are using mongo authentication. Defaults to ''.

Configuring the Mongo Tops Subsystem

master_tops:
  mongo:
    collection: tops
    id_field: _id
    re_replace: ""
    re_pattern: \.example\.com
    states_field: states
    environment_field: environment

Module Documentation

salt.tops.mongo.top(**kwargs)

Connect to a mongo database and read per-node tops data.

Parameters:
  • collection: The mongodb collection to read data from. Defaults to 'tops'.
  • id_field: The field in the collection that represents an individual minion id. Defaults to '_id'.
  • re_pattern: If your naming convention in the collection is shorter than the minion id, you can use this to trim the name. re_pattern will be used to match the name, and re_replace will be used to replace it. Backrefs are supported as they are in the Python standard library. If None, no mangling of the name will be performed - the collection will be searched with the entire minion id. Defaults to None.
  • re_replace: Use as the replacement value in node ids matched with re_pattern. Defaults to ''. Feel free to use backreferences here.
  • states_field: The name of the field providing a list of states.
  • environment_field: The name of the field providing the environment. Defaults to environment.