Advertisement
mmornati

Untitled

Mar 5th, 2014
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.61 KB | None | 0 0
  1. require 'rubygems'  # not necessary for Ruby 1.9+
  2. require 'mongo'
  3.  
  4. include Mongo
  5.  
  6. #TODO: put this into configuration file
  7. mongodb_server = "127.0.0.1"
  8. mongodb_port = 27017
  9.  
  10. mongo_client = MongoClient.new(mongodb_server, mongodb_port)
  11. puppetdb = mongo_client.db("puppet")
  12. #auth = db.authenticate(my_user_name, my_password)
  13. mco_nodes = puppetdb.collection("nodes")
  14. puts mco_nodes.find().count()
  15. #puts mco_nodes.find("fqdn" => /ser/).to_a
  16.  
  17. puts "Apache Servers: " << mco_nodes.find("facts.apache_server" => "true").count().to_s
  18. puts "MySQL Servers: " << mco_nodes.find("facts.mysql_server" => "true").count().to_s
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement