data driven infrastructure

96
Friday, August 23, 13

Upload: puppet-labs

Post on 10-May-2015

758 views

Category:

Technology


2 download

DESCRIPTION

"Data Driven Infrastructure" by James Fryman of GitHub at Puppet Camp London 2013. Find the video here: http://puppetlabs.com/community/puppet-camp

TRANSCRIPT

Page 1: Data Driven Infrastructure

Friday, August 23, 13

Page 2: Data Driven Infrastructure

DataDrivenInfrastructure

Friday, August 23, 13

Page 3: Data Driven Infrastructure

Friday, August 23, 13

Page 4: Data Driven Infrastructure

?

Friday, August 23, 13

Page 5: Data Driven Infrastructure

?

http://git.io/UmUdKAFriday, August 23, 13

Page 6: Data Driven Infrastructure

Let meTell youa story

Friday, August 23, 13

Page 7: Data Driven Infrastructure

What is a

Cloud

Friday, August 23, 13

Page 8: Data Driven Infrastructure

I don’t have to think about IT

With the Cloud...

Friday, August 23, 13

Page 9: Data Driven Infrastructure

Friday, August 23, 13

Page 10: Data Driven Infrastructure

aaSPlatformSoftware

InfrastructureFriday, August 23, 13

Page 11: Data Driven Infrastructure

Friday, August 23, 13

Page 12: Data Driven Infrastructure

Friday, August 23, 13

Page 13: Data Driven Infrastructure

Where is our cloud?

Friday, August 23, 13

Page 14: Data Driven Infrastructure

Friday, August 23, 13

Page 15: Data Driven Infrastructure

UtopiaFriday, August 23, 13

Page 16: Data Driven Infrastructure

James Fryman

Friday, August 23, 13

Page 17: Data Driven Infrastructure

Friday, August 23, 13

Page 18: Data Driven Infrastructure

Automations Junkie

Friday, August 23, 13

Page 19: Data Driven Infrastructure

Are youCrazy?

Friday, August 23, 13

Page 20: Data Driven Infrastructure

Goals?Data?What

Friday, August 23, 13

Page 21: Data Driven Infrastructure

Goals?Data?What

Friday, August 23, 13

Page 22: Data Driven Infrastructure

Goals?Data?What

Friday, August 23, 13

Page 23: Data Driven Infrastructure

Machine

Parsable

Friday, August 23, 13

Page 24: Data Driven Infrastructure

There is SystemOne

Friday, August 23, 13

Page 25: Data Driven Infrastructure

Feedback

PuppetDBProvisioning

Configuring

Destroying

gPanel

Friday, August 23, 13

Page 26: Data Driven Infrastructure

Partsof the

System

Friday, August 23, 13

Page 27: Data Driven Infrastructure

provisioner

Friday, August 23, 13

Page 28: Data Driven Infrastructure

Home GrownFriday, August 23, 13

Page 29: Data Driven Infrastructure

Home Grown

Friday, August 23, 13

Page 30: Data Driven Infrastructure

controller

Friday, August 23, 13

Page 31: Data Driven Infrastructure

Lots O’ Models

Friday, August 23, 13

Page 32: Data Driven Infrastructure

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

Page 33: Data Driven Infrastructure

orchestrator

Friday, August 23, 13

Page 34: Data Driven Infrastructure

ChatOps

Friday, August 23, 13

Page 35: Data Driven Infrastructure

ChatOps

Friday, August 23, 13

Page 36: Data Driven Infrastructure

Feedbackof the

System

Friday, August 23, 13

Page 37: Data Driven Infrastructure

Metrics&Monitoring

Friday, August 23, 13

Page 38: Data Driven Infrastructure

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']}"] endrescue ZeroDivisionError => e puts "UNKNOWN metric not in graphite!" exit EXIT_UNKNOWNrescue => e puts e.message exit EXIT_CRITICALend

Friday, August 23, 13

Page 39: Data Driven Infrastructure

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']}"] endrescue ZeroDivisionError => e puts "UNKNOWN metric not in graphite!" exit EXIT_UNKNOWNrescue => e puts e.message exit EXIT_CRITICALend

Friday, August 23, 13

Page 40: Data Driven Infrastructure

event

Friday, August 23, 13

Page 41: Data Driven Infrastructure

eventlog

Friday, August 23, 13

Page 42: Data Driven Infrastructure

eventalertlog

Friday, August 23, 13

Page 43: Data Driven Infrastructure

eventalertlog error

Friday, August 23, 13

Page 44: Data Driven Infrastructure

Must self-correct

Friday, August 23, 13

Page 45: Data Driven Infrastructure

Feedback

PuppetDBProvisioning

Configuring

Destroying

gPanel

Friday, August 23, 13

Page 46: Data Driven Infrastructure

Friday, August 23, 13

Page 47: Data Driven Infrastructure

Deployable using text files

Friday, August 23, 13

Page 48: Data Driven Infrastructure

Modularity

Friday, August 23, 13

Page 49: Data Driven Infrastructure

haproxy::proxy { $es_proxy_name: proxy => 'listen', mode => 'http', ip => $::ipaddress_lo, port => '9200', config => { balance => 'roundrobin', }, }

Friday, August 23, 13

Page 50: Data Driven Infrastructure

haproxy::proxy { $es_proxy_name: proxy => 'listen', mode => 'http', ip => $::ipaddress_lo, port => '9200', config => { balance => 'roundrobin', }, }

Friday, August 23, 13

Page 51: Data Driven Infrastructure

haproxy::proxy::member { $es_proxy_name: hostname => $::ec2_local_ipv4, port => '9200', param => [ 'weight 1', 'maxconn 1000', 'check', ], }

Friday, August 23, 13

Page 52: Data Driven Infrastructure

collectd::plugin { [ 'cpu', 'load', 'memory', 'swap', 'irq', 'exec', 'entropy', ]: } 

collectd::plugin { [ 'df', 'interface', 'protocols', 'disk', ]: config => true }

Friday, August 23, 13

Page 53: Data Driven Infrastructure

Level 4:Templates

Level 5:Data Driven

Friday, August 23, 13

Page 54: Data Driven Infrastructure

SelfAuthoritative

Friday, August 23, 13

Page 55: Data Driven Infrastructure

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

Page 56: Data Driven Infrastructure

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

Page 57: Data Driven Infrastructure

# 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

Page 58: Data Driven Infrastructure

@@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

Page 59: Data Driven Infrastructure

Tips

Friday, August 23, 13

Page 60: Data Driven Infrastructure

Refactoring

Friday, August 23, 13

Page 61: Data Driven Infrastructure

Refactoring

Friday, August 23, 13

Page 62: Data Driven Infrastructure

least to most

specificFriday, August 23, 13

Page 63: Data Driven Infrastructure

frymanet.com

mysqlnginx rails

rubycommon admin

package repos

Friday, August 23, 13

Page 64: Data Driven Infrastructure

graduate to

paramsFriday, August 23, 13

Page 65: Data Driven Infrastructure

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

Friday, August 23, 13

Page 66: Data Driven Infrastructure

externalize

Friday, August 23, 13

Page 67: Data Driven Infrastructure

class ntp::params {  $defaults = { package => { version => hiera(‘ntp_package_version’), }, config => { servers => hiera(‘ntp_servers’), }, }}

Friday, August 23, 13

Page 68: Data Driven Infrastructure

CloudFormation

Friday, August 23, 13

Page 69: Data Driven Infrastructure

CloudFormation

Friday, August 23, 13

Page 70: Data Driven Infrastructure

"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

Page 71: Data Driven Infrastructure

Autoloading

Friday, August 23, 13

Page 72: Data Driven Infrastructure

# autoloader.ppclass nagios::autoload_helpers { $helpers = get_nagios_helpers()

case $::puppetversion { /^3/: { include $helpers } default: { nagios::autoload_helpers::import_shim { $helpers: } } }}

Friday, August 23, 13

Page 73: Data Driven Infrastructure

# autoloader.ppclass nagios::autoload_helpers { $helpers = get_nagios_helpers()

case $::puppetversion { /^3/: { include $helpers } default: { nagios::autoload_helpers::import_shim { $helpers: } } }}

Friday, August 23, 13

Page 74: Data Driven Infrastructure

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 endend

Friday, August 23, 13

Page 75: Data Driven Infrastructure

Modeling

Friday, August 23, 13

Page 76: Data Driven Infrastructure

Be Dynamic

Friday, August 23, 13

Page 77: Data Driven Infrastructure

Be Dynamic

Friday, August 23, 13

Page 78: Data Driven Infrastructure

<%- 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

Page 79: Data Driven Infrastructure

Fencing Resources

Friday, August 23, 13

Page 80: Data Driven Infrastructure

# 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

Page 81: Data Driven Infrastructure

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

Page 82: Data Driven Infrastructure

Buy it?

Friday, August 23, 13

Page 83: Data Driven Infrastructure

Buy it?

Friday, August 23, 13

Page 84: Data Driven Infrastructure

It’s About

Friday, August 23, 13

Page 85: Data Driven Infrastructure

Missing?What’s

Friday, August 23, 13

Page 86: Data Driven Infrastructure

Language

Friday, August 23, 13

Page 87: Data Driven Infrastructure

Predictive Analysis

Friday, August 23, 13

Page 88: Data Driven Infrastructure

Coming

Home

Friday, August 23, 13

Page 89: Data Driven Infrastructure

Goals?Data?What

Friday, August 23, 13

Page 90: Data Driven Infrastructure

SystemsThinking

Recap

Friday, August 23, 13

Page 91: Data Driven Infrastructure

There is SystemOne

Machine

ParsableMust be aKnownQuantity

SelfAuthoritative

Must self-correctFriday, August 23, 13

Page 92: Data Driven Infrastructure

Friday, August 23, 13

Page 95: Data Driven Infrastructure

what’s next?

Friday, August 23, 13

Page 96: Data Driven Infrastructure

what’s next?

Friday, August 23, 13