Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

PuppetDB, Puppet Explorer and puppetdbquery

2,766 views

Published on

Puppet Camp Stockholm 2015

Published in: Technology
  • Be the first to comment

PuppetDB, Puppet Explorer and puppetdbquery

  1. 1. PuppetDB, Puppet Explorer and puppetdbquery Erik Dalén
  2. 2. PuppetDB Aclojure service with a PostgreSQL backend. Stores data produced by Puppet: ‣ facts ‣ catalogs ‣ reports
  3. 3. Resource collections Allows you to export and collect resources. class ssh { # Declare: @@sshkey { $hostname: type => dsa, key => $sshdsakey, } # Collect: Sshkey <<| |>> }
  4. 4. Query API PuppetDB has a rich queryAPI. Can query nodes, environments, facts, fact paths, catalogs, resources, edges, reports and events. Allows subqueries between endpoints.
  5. 5. Query API example ["and", ["in","certname", ["extract","certname", ["select_fact_contents", ["and", ["=","path",["lsbdistcodename"]], ["=","value","squeeze"]]]]], ["in","certname", ["extract","certname", ["select_resources", ["and", ["=","type","Class"], ["=","title","Nginx"], ["=","exported",false]]]]]]
  6. 6. lsbdistcodename=squeeze and class[nginx] same query in puppetdbquery
  7. 7. puppetdbquery Amodule for Puppet for querying PuppetDB with: ‣ functions ‣ clitool/puppetface ‣ hierabackend ‣ RubyAPI github.com/dalen/puppet- puppetdbquery forge.puppetlabs.com/dalen/ puppetdbquery
  8. 8. Query syntax Comparison operators = != > >= < <= ~ !~ Logical Operators and or not Fact comparisons factname = value uptime.days > 209 apt_package_updates.* ~ openssl Resource expressions type[name] { parameter = value }
  9. 9. Syntactic sugar and advanced stuff Date expressions @yesterday @"feb 1 2015" Subqueries #node.latest_report_status=failed #node { report_timestamp > @"4 hours ago" and report_timestamp < @"2 hours ago" }
  10. 10. Poor mans mcollective pssh -h <(puppet query nodes 'site=lon and class[nginx]') sudo service nginx restart
  11. 11. Puppet Explorer
  12. 12. Puppet Explorer Web UI forvisualizing data in PuppetDB. Made using CoffeeScript and AngularJS Borrows ideas from puppetdbquery and contains a JavaScript implementation of it called node- puppetdbquery
  13. 13. Demo time

×