SlideShare a Scribd company logo
1 of 66
Download to read offline
Puppet Data Mining
Report processors, stored configs and more

PuppetCamp 22nd March 2012


gareth rushgrove | morethanseven.net   http://www.flickr.com/photos/map408/2412123378
Gareth Rushgrove @garethr


gareth rushgrove | morethanseven.net
Blog at morethanseven.net


gareth rushgrove | morethanseven.net
Curate devopsweekly.com


gareth rushgrove | morethanseven.net
Text




Work at UK Government Digital Service


gareth rushgrove | morethanseven.net
Serious Government Business


gareth rushgrove | morethanseven.net
-      Why do we want it?
-      How do we get our hands on it
-      What can we build with it




Puppet data


gareth rushgrove | morethanseven.net   http://www.flickr.com/photos/iancarroll/5027441664
-      Why do we want it?
-      How do we get our hands on it
-      What can we build with it




Puppet data


gareth rushgrove | morethanseven.net   http://www.flickr.com/photos/iancarroll/5027441664
-      Why do we want it?
-      How do we get our hands on it
-      What can we build with it




Puppet data


gareth rushgrove | morethanseven.net   http://www.flickr.com/photos/iancarroll/5027441664
Why
Single source of truth


gareth rushgrove | morethanseven.net   http://www.flickr.com/photos/joeshlabotnik/4132307070/
-      Spreadsheets
-      Wiki
-      Deployment scripts
-      Application code
-      SSH configs
-      More deployment scripts
-      Monitoring configuration




Example: find a list of hostnames


gareth rushgrove | morethanseven.net
Operational reports


gareth rushgrove | morethanseven.net   http://www.flickr.com/photos/nettsu/5276327339
Company hardware




Example: hardware spreadsheet


gareth rushgrove | morethanseven.net
Hooks for tooling


gareth rushgrove | morethanseven.net   http://www.flickr.com/photos/nickstone333/3135318558
Example: Nagios integration


gareth rushgrove | morethanseven.net
Example: Rundeck integration


gareth rushgrove | morethanseven.net
How
-      Report processors
-      Stored configurations
-      Puppet internal APIs




Where to find the data


gareth rushgrove | morethanseven.net
Report processors


gareth rushgrove | morethanseven.net   http://www.flickr.com/photos/nathaninsandiego/3757033518
[agent]
     report = true
     pluginsync = true

     [master]
     reports = store
     pluginsync = true



Configuration


gareth rushgrove | morethanseven.net
[agent]
     report = true
     pluginsync = true

     [master]
     reports = store,http,log,sample
     pluginsync = true



Adding reports


gareth rushgrove | morethanseven.net
Built in


gareth rushgrove | morethanseven.net
Store the YAML report on disk. Each host sends
        its report as a YAML dump and this just stores
        the file on disk, in the reportdir directory.




Store


gareth rushgrove | morethanseven.net
Send all received logs to the local log
        destinations. Usually the log destination is syslog.




Log


gareth rushgrove | morethanseven.net
Send report information via HTTP to the
        reporturl. Each host sends its report as a YAML
        dump and this sends this YAML to a client via
        HTTP POST.




HTTP


gareth rushgrove | morethanseven.net
This report sends specific log messages to
        specific email addresses based on the tags in
        the log messages.




Tagmail


gareth rushgrove | morethanseven.net
Graph all available data about hosts using
        the RRD library.




RRDgraph


gareth rushgrove | morethanseven.net
.
     └── sample-report
         ├── lib
         │   └── puppet
         │       └── reports
         │           └── sample.rb
         └── manifests
             └── init.pp



Simple report structure


gareth rushgrove | morethanseven.net
require 'puppet'
 require 'yaml'
 require 'logger'

 LOG = Logger.new('/tmp/puppet.log')

 Puppet::Reports.register_report(:sample) do
   def process
     message = "Puppet run for #{self.host} #{self.status}"
     Puppet.debug "Hello from sample report processor"
     LOG.info message
   end
 end




Simple report processor


gareth rushgrove | morethanseven.net
require 'puppet'
 require 'yaml'
 require 'logger'

 LOG = Logger.new('/tmp/puppet.log')

 Puppet::Reports.register_report(:sample) do
   def process
     message = "Puppet run for #{self.host} #{self.status}"
     Puppet.debug "Hello from sample report processor"
     LOG.info message
   end
 end




Register report


gareth rushgrove | morethanseven.net
require 'puppet'
 require 'yaml'
 require 'logger'

 LOG = Logger.new('/tmp/puppet.log')

 Puppet::Reports.register_report(:sample) do
   def process
     message = "Puppet run for #{self.host} #{self.status}"
     Puppet.debug "Hello from sample report processor"
     LOG.info message
   end
 end




Do something with the data in self


gareth rushgrove | morethanseven.net
Open source examples


gareth rushgrove | morethanseven.net   http://www.flickr.com/photos/nettsu/5771348892
IRC/Campfire


gareth rushgrove | morethanseven.net
IRC/Campfire


gareth rushgrove | morethanseven.net
Ganglia


gareth rushgrove | morethanseven.net
Graphs!


gareth rushgrove | morethanseven.net
Zendesk


gareth rushgrove | morethanseven.net
James Turnbull will have got there first


gareth rushgrove | morethanseven.net
Stored configuration database


gareth rushgrove | morethanseven.net
[master]
     storeconfigs = true
     dbadapter = mysql
     dbuser = puppet
     dbpassword = password
     dbserver = localhost
     dbsocket = /var/run/mysql.sock



Configuration


gareth rushgrove | morethanseven.net
SQL


gareth rushgrove | morethanseven.net   http://www.flickr.com/photos/nettsu/4997777753
mysql> SHOW TABLES;
     +------------------+
     | Tables_in_puppet |
     +------------------+
     | fact_names        |
     | fact_values       |
     | hosts             |
     | inventory_facts |
     | inventory_nodes |
     | param_names       |
     | param_values      |
     | puppet_tags       |
     | resource_tags     |
     | resources         |
     | source_files      |
     +------------------+
     11 rows in set (0.00 sec)




Lots of tables to explore


gareth rushgrove | morethanseven.net
mysql> SELECT name,ip,environment,last_compile FROM hosts;
     +--------------------+-----------------+-------------+---------------------+
     | name               | ip              | environment | last_compile        |
     +--------------------+-----------------+-------------+---------------------+
     | ubuntu.localdomain | 192.168.157.129 | production | 2012-03-04 21:19:41 |
     +--------------------+-----------------+-------------+---------------------+
     1 row in set (0.00 sec)




Easily get a list of hosts


gareth rushgrove | morethanseven.net
mysql> SELECT filename,updated_at FROM source_files;
      +-----------------------------------------------------+---------------------+
      | filename                                            | updated_at          |
      +-----------------------------------------------------+---------------------+
      | NULL                                                | 2011-10-11 10:34:36 |
      | /etc/puppet/modules/users/manifests/init.pp         | 2011-10-12 14:13:49 |
      | /etc/puppet/modules/nagios/manifests/init.pp        | 2011-10-12 14:13:49 |
      | /etc/puppet/modules/ntp/manifests/init.pp           | 2011-10-12 14:13:50 |
      | /etc/puppet/modules/base_packages/manifests/init.pp | 2011-10-12 14:13:50 |
      | /etc/puppet/modules/sudo/manifests/init.pp          | 2011-10-12 14:13:50 |
      | /etc/puppet/modules/apt/manifests/init.pp           | 2011-10-12 14:13:50 |
      | /etc/puppet/modules/logrotate/manifests/init.pp     | 2011-10-12 14:13:51 |
      | /etc/puppet/modules/ganglia/manifests/init.pp       | 2011-10-12 14:13:52 |
      | /etc/puppet/modules/motd/manifests/init.pp          | 2011-10-12 14:13:57 |
      | /etc/puppet/manifests/classes.pp                    | 2011-10-12 14:17:25 |
      | /etc/puppet/modules/mysql/manifests/init.pp         | 2011-10-12 14:17:25 |
      | /etc/puppet/modules/apache2/manifests/init.pp       | 2011-10-12 14:17:25 |
      | /etc/puppet/modules/passenger/manifests/init.pp     | 2011-10-12 14:17:26 |
      +-----------------------------------------------------+---------------------+




Other interesting data too


gareth rushgrove | morethanseven.net
Active Record


gareth rushgrove | morethanseven.net   http://www.flickr.com/photos/simplebitsdan/480696708
#!/usr/bin/env ruby

    require 'puppet/rails'

    Puppet[:config] = '/etc/puppet/puppet.conf'
    Puppet.parse_config
    config = Puppet.settings.instance_variable_get(:@values)
    master_config = config[:master]




Load Puppet master configuration


gareth rushgrove | morethanseven.net
adapter = master_conf[:dbadapter]
    args = {:adapter => adapter,
      :log_level => master_conf[:rails_loglevel]}

    args[:host]                        =   master_conf[:dbserver]
    args[:username]                    =   master_conf[:dbuser]
    args[:password]                    =   master_conf[:dbpassword]
    args[:database]                    =   master_conf[:dbname]
    args[:database]                    =   "puppet" unless not args[:database].to_s.empty?
    args[:port]                        =   master_conf[:dbport]
    socket                             =   master_conf[:dbsocket]
    args[:socket]                      =   socket unless socket.to_s.empty?




Map database connection settings


gareth rushgrove | morethanseven.net
ActiveRecord::Base.establish_connection(args)

    Puppet::Rails::Host.all.each { |h|
      puts "#{h.name}"
    }




Make an active record query


gareth rushgrove | morethanseven.net
⚡ ./list.rb
      ubuntu.localdomain




Example run


gareth rushgrove | morethanseven.net
Code spelunking


gareth rushgrove | morethanseven.net
#!/usr/bin/env ruby

     require 'puppet'
     Puppet[:config] = "/etc/puppet/puppet.conf"
     Puppet.parse_config
     Puppet[:clientyamldir] = Puppet[:yamldir]
     Puppet::Node.indirection.terminus_class = :yaml




Load Puppet master configuration


gareth rushgrove | morethanseven.net
nodes = Puppet::Node.indirection.search("*")
     nodes.each do |n|
       facts = Puppet::Node::Facts.indirection.find(n.name)
       tags = Puppet::Resource::Catalog.indirection.find(n.name).tags
       puts "#{n.name} - #{tags.join(', ')}"
     end




Make a query using the internal API


gareth rushgrove | morethanseven.net
⚡ sudo ./puppettags.rb
      ubuntu.localdomain - settings, default, node




Needs root permissions


gareth rushgrove | morethanseven.net
What
⚡ ./puppetlast.rb
      +-----------+-----------------+
      | hostname | last puppet run |
      +-----------+-----------------+
      | hostname4 | 100 minutes     |
      | hostname1 | 25 minutes      |
      | hostname5 | 10 minutes      |
      | hostname2 | 15 minutes      |
      | hostname3 | 5 minutes       |
      +-----------+-----------------+



Command line tools


gareth rushgrove | morethanseven.net
Dashboards


gareth rushgrove | morethanseven.net
web-puppet


gareth rushgrove | morethanseven.net
JSON over HTTP


gareth rushgrove | morethanseven.net
capistrano-puppet


gareth rushgrove | morethanseven.net
require 'capistrano-puppet'

     web_puppet = CapistranoPuppet::Server.new(
       'http://username:password@localhost:9295')

     role :web do
       web_puppet.get_servers('webserver')
     end




Get hosts from puppet


gareth rushgrove | morethanseven.net
Visualisation


gareth rushgrove | morethanseven.net
Your imagination
                                       ?
gareth rushgrove | morethanseven.net
-      web-puppet - https://github.com/garethr/web-puppet
-      capistrano-puppet - https://github.com/garethr/capistrano-puppet
-      puppet-ganglia - https://github.com/jamtur01/puppet-ganglia
-      puppet-zendesk - https://github.com/jamtur01/puppet-zendesk
-      puppet-irc - https://github.com/jamtur01/puppet-irc
-      puppet-campfire - https://github.com/jamtur01/puppet-campfire




Links


gareth rushgrove | morethanseven.net
One more thing


gareth rushgrove | morethanseven.net   http://www.flickr.com/photos/benterrett/6852348725/
Questions?


gareth rushgrove | morethanseven.net   http://flickr.com/photos/psd/102332391/

More Related Content

What's hot

What's hot (20)

Vagrant and Configuration Management
Vagrant and Configuration ManagementVagrant and Configuration Management
Vagrant and Configuration Management
 
THE RED METHOD: HOW TO INSTRUMENT YOUR SERVICES
THE RED METHOD: HOW TO INSTRUMENT YOUR SERVICESTHE RED METHOD: HOW TO INSTRUMENT YOUR SERVICES
THE RED METHOD: HOW TO INSTRUMENT YOUR SERVICES
 
No Hugging, No Learning
No Hugging, No LearningNo Hugging, No Learning
No Hugging, No Learning
 
Noah Zoschke at Waza 2013: Heroku Secrets
Noah Zoschke at Waza 2013: Heroku SecretsNoah Zoschke at Waza 2013: Heroku Secrets
Noah Zoschke at Waza 2013: Heroku Secrets
 
Building Docker images with Puppet
Building Docker images with PuppetBuilding Docker images with Puppet
Building Docker images with Puppet
 
vBACD - Introduction to Opscode Chef - 2/29
vBACD - Introduction to Opscode Chef - 2/29vBACD - Introduction to Opscode Chef - 2/29
vBACD - Introduction to Opscode Chef - 2/29
 
Release with confidence
Release with confidenceRelease with confidence
Release with confidence
 
Big query - Command line tools and Tips - (MOSG)
Big query - Command line tools and Tips - (MOSG)Big query - Command line tools and Tips - (MOSG)
Big query - Command line tools and Tips - (MOSG)
 
GDG Devfest 2019 - Build go kit microservices at kubernetes with ease
GDG Devfest 2019 - Build go kit microservices at kubernetes with easeGDG Devfest 2019 - Build go kit microservices at kubernetes with ease
GDG Devfest 2019 - Build go kit microservices at kubernetes with ease
 
如何透過 Go-kit 快速搭建微服務架構應用程式實戰
如何透過 Go-kit 快速搭建微服務架構應用程式實戰如何透過 Go-kit 快速搭建微服務架構應用程式實戰
如何透過 Go-kit 快速搭建微服務架構應用程式實戰
 
Analysing Github events with Neo4j
Analysing Github events with Neo4jAnalysing Github events with Neo4j
Analysing Github events with Neo4j
 
Infrastructure = code - 1 year later
Infrastructure = code - 1 year laterInfrastructure = code - 1 year later
Infrastructure = code - 1 year later
 
Weird things we've seen with OpenStack Neutron
Weird things we've seen with OpenStack NeutronWeird things we've seen with OpenStack Neutron
Weird things we've seen with OpenStack Neutron
 
Introduzione a GitHub Actions (beta)
Introduzione a GitHub Actions (beta)Introduzione a GitHub Actions (beta)
Introduzione a GitHub Actions (beta)
 
Plone deployment made easy
Plone deployment made easyPlone deployment made easy
Plone deployment made easy
 
Docker in Action
Docker in ActionDocker in Action
Docker in Action
 
Mangling
Mangling Mangling
Mangling
 
SDPHP - Percona Toolkit (It's Basically Magic)
SDPHP - Percona Toolkit (It's Basically Magic)SDPHP - Percona Toolkit (It's Basically Magic)
SDPHP - Percona Toolkit (It's Basically Magic)
 
Background processing with Resque
Background processing with ResqueBackground processing with Resque
Background processing with Resque
 
Background Jobs with Resque
Background Jobs with ResqueBackground Jobs with Resque
Background Jobs with Resque
 

Viewers also liked

Viewers also liked (10)

Communications Between Tribes
Communications Between TribesCommunications Between Tribes
Communications Between Tribes
 
Two Sides of Google Infrastructure for Everyone Else
Two Sides of Google Infrastructure for Everyone ElseTwo Sides of Google Infrastructure for Everyone Else
Two Sides of Google Infrastructure for Everyone Else
 
What to Build with Google App Engine
What to Build with Google App EngineWhat to Build with Google App Engine
What to Build with Google App Engine
 
Social Media Risk and Reputation Management
Social Media Risk and Reputation ManagementSocial Media Risk and Reputation Management
Social Media Risk and Reputation Management
 
Dev opsdays scriptcode
Dev opsdays scriptcodeDev opsdays scriptcode
Dev opsdays scriptcode
 
Ruby
RubyRuby
Ruby
 
Thinking Evil Thoughts
Thinking Evil ThoughtsThinking Evil Thoughts
Thinking Evil Thoughts
 
introduction to python
introduction to pythonintroduction to python
introduction to python
 
DevOps at DreamLab
DevOps at DreamLabDevOps at DreamLab
DevOps at DreamLab
 
Overview of Chef - Fundamentals Webinar Series Part 1
Overview of Chef - Fundamentals Webinar Series Part 1Overview of Chef - Fundamentals Webinar Series Part 1
Overview of Chef - Fundamentals Webinar Series Part 1
 

Similar to Puppet Data Mining

Config managament for development environments iii
Config managament for development environments iiiConfig managament for development environments iii
Config managament for development environments iii
Puppet
 
2012 coscup - Build your PHP application on Heroku
2012 coscup - Build your PHP application on Heroku2012 coscup - Build your PHP application on Heroku
2012 coscup - Build your PHP application on Heroku
ronnywang_tw
 
fog or: How I Learned to Stop Worrying and Love the Cloud (OpenStack Edition)
fog or: How I Learned to Stop Worrying and Love the Cloud (OpenStack Edition)fog or: How I Learned to Stop Worrying and Love the Cloud (OpenStack Edition)
fog or: How I Learned to Stop Worrying and Love the Cloud (OpenStack Edition)
Wesley Beary
 
Встраиваем python для появления аналитики в проекте на С++. Александр Боргард...
Встраиваем python для появления аналитики в проекте на С++. Александр Боргард...Встраиваем python для появления аналитики в проекте на С++. Александр Боргард...
Встраиваем python для появления аналитики в проекте на С++. Александр Боргард...
corehard_by
 
Common schema my sql uc 2012
Common schema   my sql uc 2012Common schema   my sql uc 2012
Common schema my sql uc 2012
Roland Bouman
 
Common schema my sql uc 2012
Common schema   my sql uc 2012Common schema   my sql uc 2012
Common schema my sql uc 2012
Roland Bouman
 
pg_proctab: Accessing System Stats in PostgreSQL
pg_proctab: Accessing System Stats in PostgreSQLpg_proctab: Accessing System Stats in PostgreSQL
pg_proctab: Accessing System Stats in PostgreSQL
Command Prompt., Inc
 

Similar to Puppet Data Mining (20)

Config managament for development environments iii
Config managament for development environments iiiConfig managament for development environments iii
Config managament for development environments iii
 
Metrics with Ganglia
Metrics with GangliaMetrics with Ganglia
Metrics with Ganglia
 
Logstash for SEO: come monitorare i Log del Web Server in realtime
Logstash for SEO: come monitorare i Log del Web Server in realtimeLogstash for SEO: come monitorare i Log del Web Server in realtime
Logstash for SEO: come monitorare i Log del Web Server in realtime
 
10 things I learned building Nomad packs
10 things I learned building Nomad packs10 things I learned building Nomad packs
10 things I learned building Nomad packs
 
KubeCon EU 2016: Kubernetes and the Potential for Higher Level Interfaces
KubeCon EU 2016: Kubernetes and the Potential for Higher Level InterfacesKubeCon EU 2016: Kubernetes and the Potential for Higher Level Interfaces
KubeCon EU 2016: Kubernetes and the Potential for Higher Level Interfaces
 
2012 coscup - Build your PHP application on Heroku
2012 coscup - Build your PHP application on Heroku2012 coscup - Build your PHP application on Heroku
2012 coscup - Build your PHP application on Heroku
 
Network Automation: Ansible 102
Network Automation: Ansible 102Network Automation: Ansible 102
Network Automation: Ansible 102
 
Best Practices in Handling Performance Issues
Best Practices in Handling Performance IssuesBest Practices in Handling Performance Issues
Best Practices in Handling Performance Issues
 
Bare-metal and Virtual Provisioning with Razor
Bare-metal and Virtual Provisioning with RazorBare-metal and Virtual Provisioning with Razor
Bare-metal and Virtual Provisioning with Razor
 
Integrating ChatGPT with Apache Airflow
Integrating ChatGPT with Apache AirflowIntegrating ChatGPT with Apache Airflow
Integrating ChatGPT with Apache Airflow
 
fog or: How I Learned to Stop Worrying and Love the Cloud (OpenStack Edition)
fog or: How I Learned to Stop Worrying and Love the Cloud (OpenStack Edition)fog or: How I Learned to Stop Worrying and Love the Cloud (OpenStack Edition)
fog or: How I Learned to Stop Worrying and Love the Cloud (OpenStack Edition)
 
fog or: How I Learned to Stop Worrying and Love the Cloud
fog or: How I Learned to Stop Worrying and Love the Cloudfog or: How I Learned to Stop Worrying and Love the Cloud
fog or: How I Learned to Stop Worrying and Love the Cloud
 
Встраиваем python для появления аналитики в проекте на С++. Александр Боргард...
Встраиваем python для появления аналитики в проекте на С++. Александр Боргард...Встраиваем python для появления аналитики в проекте на С++. Александр Боргард...
Встраиваем python для появления аналитики в проекте на С++. Александр Боргард...
 
PostgreSQL - Haute disponibilité avec Patroni
PostgreSQL - Haute disponibilité avec PatroniPostgreSQL - Haute disponibilité avec Patroni
PostgreSQL - Haute disponibilité avec Patroni
 
Malware Detection with OSSEC HIDS - OSSECCON 2014
Malware Detection with OSSEC HIDS - OSSECCON 2014Malware Detection with OSSEC HIDS - OSSECCON 2014
Malware Detection with OSSEC HIDS - OSSECCON 2014
 
Common schema my sql uc 2012
Common schema   my sql uc 2012Common schema   my sql uc 2012
Common schema my sql uc 2012
 
Common schema my sql uc 2012
Common schema   my sql uc 2012Common schema   my sql uc 2012
Common schema my sql uc 2012
 
Linux Desktop Automation
Linux Desktop AutomationLinux Desktop Automation
Linux Desktop Automation
 
pg_proctab: Accessing System Stats in PostgreSQL
pg_proctab: Accessing System Stats in PostgreSQLpg_proctab: Accessing System Stats in PostgreSQL
pg_proctab: Accessing System Stats in PostgreSQL
 
pg_proctab: Accessing System Stats in PostgreSQL
pg_proctab: Accessing System Stats in PostgreSQLpg_proctab: Accessing System Stats in PostgreSQL
pg_proctab: Accessing System Stats in PostgreSQL
 

More from Gareth Rushgrove

More from Gareth Rushgrove (16)

Web operations
Web operationsWeb operations
Web operations
 
You're Going To Need A Bigger Toolbox
You're Going To Need A Bigger ToolboxYou're Going To Need A Bigger Toolbox
You're Going To Need A Bigger Toolbox
 
Devops
DevopsDevops
Devops
 
Message Queues for Web Applications
Message Queues for Web ApplicationsMessage Queues for Web Applications
Message Queues for Web Applications
 
Beyond basic web development
Beyond basic web developmentBeyond basic web development
Beyond basic web development
 
Self Education for Web Professionals
Self Education for Web ProfessionalsSelf Education for Web Professionals
Self Education for Web Professionals
 
App Engine for Python Developers
App Engine for Python DevelopersApp Engine for Python Developers
App Engine for Python Developers
 
Testing Django Applications
Testing Django ApplicationsTesting Django Applications
Testing Django Applications
 
Design Strategies for a Distributed Web
Design Strategies for a Distributed WebDesign Strategies for a Distributed Web
Design Strategies for a Distributed Web
 
A First Class Web Citizen
A First Class Web CitizenA First Class Web Citizen
A First Class Web Citizen
 
Parsing Microformats
Parsing MicroformatsParsing Microformats
Parsing Microformats
 
Things you probably don't do (or tying to make project automation sexy)
Things you probably don't do (or tying to make project automation sexy)Things you probably don't do (or tying to make project automation sexy)
Things you probably don't do (or tying to make project automation sexy)
 
Notes from (Web 2.0) Revolution
Notes from (Web 2.0) RevolutionNotes from (Web 2.0) Revolution
Notes from (Web 2.0) Revolution
 
Rails flavoured OpenId
Rails flavoured OpenIdRails flavoured OpenId
Rails flavoured OpenId
 
Shiny Content Management with Radiant
Shiny Content Management with RadiantShiny Content Management with Radiant
Shiny Content Management with Radiant
 
RESTful Rabbits
RESTful RabbitsRESTful Rabbits
RESTful Rabbits
 

Recently uploaded

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Recently uploaded (20)

Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 

Puppet Data Mining

  • 1. Puppet Data Mining Report processors, stored configs and more PuppetCamp 22nd March 2012 gareth rushgrove | morethanseven.net http://www.flickr.com/photos/map408/2412123378
  • 2. Gareth Rushgrove @garethr gareth rushgrove | morethanseven.net
  • 3. Blog at morethanseven.net gareth rushgrove | morethanseven.net
  • 5. Text Work at UK Government Digital Service gareth rushgrove | morethanseven.net
  • 6. Serious Government Business gareth rushgrove | morethanseven.net
  • 7. - Why do we want it? - How do we get our hands on it - What can we build with it Puppet data gareth rushgrove | morethanseven.net http://www.flickr.com/photos/iancarroll/5027441664
  • 8. - Why do we want it? - How do we get our hands on it - What can we build with it Puppet data gareth rushgrove | morethanseven.net http://www.flickr.com/photos/iancarroll/5027441664
  • 9. - Why do we want it? - How do we get our hands on it - What can we build with it Puppet data gareth rushgrove | morethanseven.net http://www.flickr.com/photos/iancarroll/5027441664
  • 10. Why
  • 11. Single source of truth gareth rushgrove | morethanseven.net http://www.flickr.com/photos/joeshlabotnik/4132307070/
  • 12. - Spreadsheets - Wiki - Deployment scripts - Application code - SSH configs - More deployment scripts - Monitoring configuration Example: find a list of hostnames gareth rushgrove | morethanseven.net
  • 13. Operational reports gareth rushgrove | morethanseven.net http://www.flickr.com/photos/nettsu/5276327339
  • 14. Company hardware Example: hardware spreadsheet gareth rushgrove | morethanseven.net
  • 15. Hooks for tooling gareth rushgrove | morethanseven.net http://www.flickr.com/photos/nickstone333/3135318558
  • 16. Example: Nagios integration gareth rushgrove | morethanseven.net
  • 17. Example: Rundeck integration gareth rushgrove | morethanseven.net
  • 18. How
  • 19. - Report processors - Stored configurations - Puppet internal APIs Where to find the data gareth rushgrove | morethanseven.net
  • 20. Report processors gareth rushgrove | morethanseven.net http://www.flickr.com/photos/nathaninsandiego/3757033518
  • 21. [agent] report = true pluginsync = true [master] reports = store pluginsync = true Configuration gareth rushgrove | morethanseven.net
  • 22. [agent] report = true pluginsync = true [master] reports = store,http,log,sample pluginsync = true Adding reports gareth rushgrove | morethanseven.net
  • 23. Built in gareth rushgrove | morethanseven.net
  • 24. Store the YAML report on disk. Each host sends its report as a YAML dump and this just stores the file on disk, in the reportdir directory. Store gareth rushgrove | morethanseven.net
  • 25. Send all received logs to the local log destinations. Usually the log destination is syslog. Log gareth rushgrove | morethanseven.net
  • 26. Send report information via HTTP to the reporturl. Each host sends its report as a YAML dump and this sends this YAML to a client via HTTP POST. HTTP gareth rushgrove | morethanseven.net
  • 27. This report sends specific log messages to specific email addresses based on the tags in the log messages. Tagmail gareth rushgrove | morethanseven.net
  • 28. Graph all available data about hosts using the RRD library. RRDgraph gareth rushgrove | morethanseven.net
  • 29. . └── sample-report ├── lib │   └── puppet │   └── reports │   └── sample.rb └── manifests └── init.pp Simple report structure gareth rushgrove | morethanseven.net
  • 30. require 'puppet' require 'yaml' require 'logger' LOG = Logger.new('/tmp/puppet.log') Puppet::Reports.register_report(:sample) do def process message = "Puppet run for #{self.host} #{self.status}" Puppet.debug "Hello from sample report processor" LOG.info message end end Simple report processor gareth rushgrove | morethanseven.net
  • 31. require 'puppet' require 'yaml' require 'logger' LOG = Logger.new('/tmp/puppet.log') Puppet::Reports.register_report(:sample) do def process message = "Puppet run for #{self.host} #{self.status}" Puppet.debug "Hello from sample report processor" LOG.info message end end Register report gareth rushgrove | morethanseven.net
  • 32. require 'puppet' require 'yaml' require 'logger' LOG = Logger.new('/tmp/puppet.log') Puppet::Reports.register_report(:sample) do def process message = "Puppet run for #{self.host} #{self.status}" Puppet.debug "Hello from sample report processor" LOG.info message end end Do something with the data in self gareth rushgrove | morethanseven.net
  • 33. Open source examples gareth rushgrove | morethanseven.net http://www.flickr.com/photos/nettsu/5771348892
  • 34. IRC/Campfire gareth rushgrove | morethanseven.net
  • 35. IRC/Campfire gareth rushgrove | morethanseven.net
  • 36. Ganglia gareth rushgrove | morethanseven.net
  • 37. Graphs! gareth rushgrove | morethanseven.net
  • 38. Zendesk gareth rushgrove | morethanseven.net
  • 39. James Turnbull will have got there first gareth rushgrove | morethanseven.net
  • 40. Stored configuration database gareth rushgrove | morethanseven.net
  • 41. [master] storeconfigs = true dbadapter = mysql dbuser = puppet dbpassword = password dbserver = localhost dbsocket = /var/run/mysql.sock Configuration gareth rushgrove | morethanseven.net
  • 42. SQL gareth rushgrove | morethanseven.net http://www.flickr.com/photos/nettsu/4997777753
  • 43. mysql> SHOW TABLES; +------------------+ | Tables_in_puppet | +------------------+ | fact_names | | fact_values | | hosts | | inventory_facts | | inventory_nodes | | param_names | | param_values | | puppet_tags | | resource_tags | | resources | | source_files | +------------------+ 11 rows in set (0.00 sec) Lots of tables to explore gareth rushgrove | morethanseven.net
  • 44. mysql> SELECT name,ip,environment,last_compile FROM hosts; +--------------------+-----------------+-------------+---------------------+ | name | ip | environment | last_compile | +--------------------+-----------------+-------------+---------------------+ | ubuntu.localdomain | 192.168.157.129 | production | 2012-03-04 21:19:41 | +--------------------+-----------------+-------------+---------------------+ 1 row in set (0.00 sec) Easily get a list of hosts gareth rushgrove | morethanseven.net
  • 45. mysql> SELECT filename,updated_at FROM source_files; +-----------------------------------------------------+---------------------+ | filename | updated_at | +-----------------------------------------------------+---------------------+ | NULL | 2011-10-11 10:34:36 | | /etc/puppet/modules/users/manifests/init.pp | 2011-10-12 14:13:49 | | /etc/puppet/modules/nagios/manifests/init.pp | 2011-10-12 14:13:49 | | /etc/puppet/modules/ntp/manifests/init.pp | 2011-10-12 14:13:50 | | /etc/puppet/modules/base_packages/manifests/init.pp | 2011-10-12 14:13:50 | | /etc/puppet/modules/sudo/manifests/init.pp | 2011-10-12 14:13:50 | | /etc/puppet/modules/apt/manifests/init.pp | 2011-10-12 14:13:50 | | /etc/puppet/modules/logrotate/manifests/init.pp | 2011-10-12 14:13:51 | | /etc/puppet/modules/ganglia/manifests/init.pp | 2011-10-12 14:13:52 | | /etc/puppet/modules/motd/manifests/init.pp | 2011-10-12 14:13:57 | | /etc/puppet/manifests/classes.pp | 2011-10-12 14:17:25 | | /etc/puppet/modules/mysql/manifests/init.pp | 2011-10-12 14:17:25 | | /etc/puppet/modules/apache2/manifests/init.pp | 2011-10-12 14:17:25 | | /etc/puppet/modules/passenger/manifests/init.pp | 2011-10-12 14:17:26 | +-----------------------------------------------------+---------------------+ Other interesting data too gareth rushgrove | morethanseven.net
  • 46. Active Record gareth rushgrove | morethanseven.net http://www.flickr.com/photos/simplebitsdan/480696708
  • 47. #!/usr/bin/env ruby require 'puppet/rails' Puppet[:config] = '/etc/puppet/puppet.conf' Puppet.parse_config config = Puppet.settings.instance_variable_get(:@values) master_config = config[:master] Load Puppet master configuration gareth rushgrove | morethanseven.net
  • 48. adapter = master_conf[:dbadapter] args = {:adapter => adapter, :log_level => master_conf[:rails_loglevel]} args[:host] = master_conf[:dbserver] args[:username] = master_conf[:dbuser] args[:password] = master_conf[:dbpassword] args[:database] = master_conf[:dbname] args[:database] = "puppet" unless not args[:database].to_s.empty? args[:port] = master_conf[:dbport] socket = master_conf[:dbsocket] args[:socket] = socket unless socket.to_s.empty? Map database connection settings gareth rushgrove | morethanseven.net
  • 49. ActiveRecord::Base.establish_connection(args) Puppet::Rails::Host.all.each { |h| puts "#{h.name}" } Make an active record query gareth rushgrove | morethanseven.net
  • 50. ⚡ ./list.rb ubuntu.localdomain Example run gareth rushgrove | morethanseven.net
  • 51. Code spelunking gareth rushgrove | morethanseven.net
  • 52. #!/usr/bin/env ruby require 'puppet' Puppet[:config] = "/etc/puppet/puppet.conf" Puppet.parse_config Puppet[:clientyamldir] = Puppet[:yamldir] Puppet::Node.indirection.terminus_class = :yaml Load Puppet master configuration gareth rushgrove | morethanseven.net
  • 53. nodes = Puppet::Node.indirection.search("*") nodes.each do |n| facts = Puppet::Node::Facts.indirection.find(n.name) tags = Puppet::Resource::Catalog.indirection.find(n.name).tags puts "#{n.name} - #{tags.join(', ')}" end Make a query using the internal API gareth rushgrove | morethanseven.net
  • 54. ⚡ sudo ./puppettags.rb ubuntu.localdomain - settings, default, node Needs root permissions gareth rushgrove | morethanseven.net
  • 55. What
  • 56. ⚡ ./puppetlast.rb +-----------+-----------------+ | hostname | last puppet run | +-----------+-----------------+ | hostname4 | 100 minutes | | hostname1 | 25 minutes | | hostname5 | 10 minutes | | hostname2 | 15 minutes | | hostname3 | 5 minutes | +-----------+-----------------+ Command line tools gareth rushgrove | morethanseven.net
  • 57. Dashboards gareth rushgrove | morethanseven.net
  • 58. web-puppet gareth rushgrove | morethanseven.net
  • 59. JSON over HTTP gareth rushgrove | morethanseven.net
  • 61. require 'capistrano-puppet' web_puppet = CapistranoPuppet::Server.new( 'http://username:password@localhost:9295') role :web do web_puppet.get_servers('webserver') end Get hosts from puppet gareth rushgrove | morethanseven.net
  • 62. Visualisation gareth rushgrove | morethanseven.net
  • 63. Your imagination ? gareth rushgrove | morethanseven.net
  • 64. - web-puppet - https://github.com/garethr/web-puppet - capistrano-puppet - https://github.com/garethr/capistrano-puppet - puppet-ganglia - https://github.com/jamtur01/puppet-ganglia - puppet-zendesk - https://github.com/jamtur01/puppet-zendesk - puppet-irc - https://github.com/jamtur01/puppet-irc - puppet-campfire - https://github.com/jamtur01/puppet-campfire Links gareth rushgrove | morethanseven.net
  • 65. One more thing gareth rushgrove | morethanseven.net http://www.flickr.com/photos/benterrett/6852348725/
  • 66. Questions? gareth rushgrove | morethanseven.net http://flickr.com/photos/psd/102332391/