Ansible inventory stored in mongodb
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

turret (deprecated, pillbox is going to replace this)

Turret is a cli tool to store the ansible inventory in mongodb instead of flat files. It plugs right into ansible as dynamic inventory, see Dynamic Inventory and Developing Dynamic Inventory Sources.

Install (ubuntu)

git clone

cd turret

sudo python install

create config ~/.turretrc

    user: "inventory"
    password: "verysecretpassword"
    host: ""
    port: 27017
    database: "inventory"
    meta: True
    format: "YAML"

Instal mongodb server

sudo apt-get install mongodb-server

text indexes in mongodb

db.hosts.createIndex({"$**": "text" }, { name: "hostIndex", background: true } )
db.groups.createIndex({"$**": "text" }, { name: "groupIndex", background: true } )

show output for ansible:

 turret --list

basic commands

# add new host:
$ turret -s --add

# edit host vars with your favorite editor defined in EDITOR environment variable:
$ turret -s -e

# show all hosts with data:
$ turret -s -m
- _id:
  groups: {}
  - var: foo

# add alias
$ turret -s --add-alias new

# show all hosts
$ turret -S -m
- _id:
  - new
  groups: {}
  - var: foo

$ turret -s --add-group allnewservers

# show group
$ turret -g allnewservers

# show all groups
$ turret -G -m

# add child group
turret -g parent --add-child childgroup

Mongo schema

Example host:

  • name: alias:
    • server1 groups:
    • directadmin
    • vps vars: ansible_ssh_host: ansible_ssh_port: 22 ansible_ssh_user: root directadmin_port: '2222' nagios_description: 'server1' nagios_parents: '' varnish_backend_ip: varnish_backend_port: 80 varnish_listen_ip: varnish_listen_port: 6081

Example group:

  • name: webservers children:
    • wordpress
    • magento
    • shared vars: collectd_plugins_apache: true nagios_check_disk_c: 3% nagios_check_disk_dev: /dev/vda nagios_check_disk_w: 5%


I'm not a experienced programmer, so suggestions and contributions are very welcome.



Free Software, please contribute!