Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Building Data-Driven Infrastructure with Puppet

Building Data-Driven Infrastructure with Puppet

The road to Data Driven Infrastructure is a hard and long one, but a worthwhile endeavor in the lifecycle of Information Technology and Business Enablement. This talk is a snapshot of the voyage of one man's quest to have computers absolutely and completely take over his job, the patterns that have been uncovered, and the things we as an industry need to keep pushing on.

This talk can be viewed online at https://www.youtube.com/watch?v=vEpXJRPITN0&list=PLV86BgbREluU02Ytlz80seDSKAbkx5pRg

James Fryman

August 22, 2013
Tweet

More Decks by James Fryman

Other Decks in Technology

Transcript

  1. file { '/etc/facter/facts.d/quagga_manage_service': ensure => present, replace => false, }

    if $::quagga_manage_service { $service_state[ensure] = running $service_state[enable] = true } else { $service_state[ensure] = undef $service_state[enable] = undef } service { 'quagga': ensure => $service_state[ensure], enable => $service_state[enable], } Friday, August 23, 13
  2. 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
  3. 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
  4. haproxy::proxy { $es_proxy_name: proxy => 'listen', mode => 'http', ip

    => $::ipaddress_lo, port => '9200', config => { balance => 'roundrobin', }, } Friday, August 23, 13
  5. haproxy::proxy { $es_proxy_name: proxy => 'listen', mode => 'http', ip

    => $::ipaddress_lo, port => '9200', config => { balance => 'roundrobin', }, } Friday, August 23, 13
  6. haproxy::proxy::member { $es_proxy_name: hostname => $::ec2_local_ipv4, port => '9200', param

    => [ 'weight 1', 'maxconn 1000', 'check', ], } Friday, August 23, 13
  7. collectd::plugin { [ 'cpu', 'load', 'memory', 'swap', 'irq', 'exec', 'entropy',

    ]: } collectd::plugin { [ 'df', 'interface', 'protocols', 'disk', ]: config => true } Friday, August 23, 13
  8. def self.collect_resources(resource) query = [ "and", ["=", "type", "File"], ["=",

    "exported", true], ["=", "tag", "nagios::object::#{resource}"], ["=", ["node", "active"], true] ] self.search('/v2/resources', query.to_json) end Friday, August 23, 13
  9. def self.collect_resources(resource) query = [ "and", ["=", "type", "File"], ["=",

    "exported", true], ["=", "tag", "nagios::object::#{resource}"], ["=", ["node", "active"], true] ] self.search('/v2/resources', query.to_json) end Friday, August 23, 13
  10. # 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
  11. class ntp::params { $defaults = { package => { version

    => ‘latest’, }, config => { servers => [‘pool.ntp.org’], }, } } Friday, August 23, 13
  12. class ntp::params { $defaults = { package => { version

    => hiera(‘ntp_package_version’), }, config => { servers => hiera(‘ntp_servers’), }, } } Friday, August 23, 13
  13. "Resources": { "RendererServerGroup": { "Type": "AWS::AutoScaling::AutoScalingGroup", "Properties": { "AvailabilityZones": {

    "Fn::GetAZs": "" }, "LaunchConfigurationName": { "Ref": "LaunchConfig" }, "MinSize": "2", "MaxSize": "16", "Tags": [ { "Key": "Environment", "Value": "Production", "PropagateAtLaunch": "true" }, { "Key": "Role", "Value": "renderer", "PropagateAtLaunch": "true" } ] } }, Friday, August 23, 13
  14. # 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
  15. # 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
  16. 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
  17. <%- if @comment -%> ### <%= @comment %> <%- end

    -%> <%= @type %> <% if @label %><%= @label %><% end %> { <%- @config.sort.reverse.each do | key,value| -%> <%- if value.class == Array -%> <%- value.each do |element| - %> <%= key %>(<%= element %>); <%- end -%> <%- else -%> <%= key %>(<%= value %>); <%- end -%> <%- end -%> }; Friday, August 23, 13
  18. # 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
  19. There is System One Machine Parsable Must be a Known

    Quantity Self Authoritative Must self-correct Friday, August 23, 13