"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
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
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
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
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
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
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
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