"Building Data-Driven Infrastructure with Puppet" by James Fryman, Operations Hacker, GitHub, Inc.
Presentation Overview: As your Puppet Infrastructure grows, so does the complexity of the Puppet codebase. The complexity of the codebase often creates a scenario where it becomes more time consuming to modify/add to the codebase. Likewise, any new addition or node still may require modifications to the Puppet database, which could include the management of many edge cases. Fortunately, the software industry has been working on developing techniques with code abstraction, refactoring, and software maturity. This talk will focus on how to write scalable modules within Puppet to be used to create Data Driven Infrastructures. In addition, this talk will demonstrate how to structure process/procedure/code to quickly and rapidly scale operations with minimal modifications to Puppet code.
Speaker Bio: James Fryman, Operations Hacker, GitHub, Inc. James Fryman is a Technologist who has been working on spreading the good word of technology via the greatest mechanism known to man: the beer fueled rant. James has been working to automate software and infrastructure for the last 10 years, and has learned quite a bit about Security, Architecture, Scaling, and Development as a result. James currently works for GitHub as an Operations Hacker.
38. begin
JSON.parse(RestClient.get(url)).each do |cache|
data["#{cache['target']}"] = 0
count = 0
cache["datapoints"].each do |point|
unless (point[0].nil?)
data["#{cache['target']}"] += point[0]
count += 1
end
end
data["#{cache['target']}"] /= count
data["total"] += data["#{cache['target']}"]
end
rescue ZeroDivisionError => e
puts "UNKNOWN metric not in graphite!"
exit EXIT_UNKNOWN
rescue => e
puts e.message
exit EXIT_CRITICAL
end
Friday, August 23, 13
39. begin
JSON.parse(RestClient.get(url)).each do |cache|
data["#{cache['target']}"] = 0
count = 0
cache["datapoints"].each do |point|
unless (point[0].nil?)
data["#{cache['target']}"] += point[0]
count += 1
end
end
data["#{cache['target']}"] /= count
data["total"] += data["#{cache['target']}"]
end
rescue ZeroDivisionError => e
puts "UNKNOWN metric not in graphite!"
exit EXIT_UNKNOWN
rescue => e
puts e.message
exit EXIT_CRITICAL
end
Friday, August 23, 13
57. # Seed the initial file with false, and enable
# on next run with gh-nagios enable_pager <hostname>
file { '/etc/facter/facts.d/enable_pager.txt':
ensure => file,
owner => 'root',
group => 'root',
mode => '0644',
content => 'enable_pager=false',
replace => false,
}
Friday, August 23, 13
72. # autoloader.pp
class nagios::autoload_helpers {
$helpers = get_nagios_helpers()
case $::puppetversion {
/^3/: { include $helpers }
default: {
nagios::autoload_helpers::import_shim { $helpers: }
}
}
}
Friday, August 23, 13
73. # autoloader.pp
class nagios::autoload_helpers {
$helpers = get_nagios_helpers()
case $::puppetversion {
/^3/: { include $helpers }
default: {
nagios::autoload_helpers::import_shim { $helpers: }
}
}
}
Friday, August 23, 13
74. module Puppet::Parser::Functions
newfunction(:get_nagios_helpers,
:type => :rvalue,
:doc => "Grab all modules that have nagios helpers for
import") do
module_path = File.expand_path('..',
Puppet::Module.find('nagios',compiler.environment.to_s).path)
helpers = Dir["#{module_path}/**/nagios/helpers.pp"].map do |d|
"#{d.split('/')[-4]}::nagios::helpers"
done
helpers
end
end
Friday, August 23, 13
80. # Seed the initial file with false, and enable
# on next run with gh-nagios enable_pager <hostname>
file { '/etc/facter/facts.d/enable_pager.txt':
ensure => file,
owner => 'root',
group => 'root',
mode => '0644',
content => 'enable_pager=false',
replace => false,
}
Friday, August 23, 13
81. if $::enable_pager {
@@file { "/etc/nagios/objects/${type}.d/${filename}.cfg":
content => template('nagios/etc/nagios/object.erb'),
mode => '0444',
group => 'nagios',
notify => Service['nagios'],
}
}
Friday, August 23, 13