streamlining workflows with puppet faces

128
PUPPET FACES Streamlining Workflows Kelsey Hightower

Upload: kelsey-hightower

Post on 11-Nov-2014

6.854 views

Category:

Technology


1 download

DESCRIPTION

An in depth look at the Puppet Faces API and how to leverage it to streamline your configuration management workflow. During this talk a data driven Puppet Face will be created from the ground up. The goal is to automate a common workflow scenario which involves updating Puppet Dashboard external node configuration (ENC) data in bulk.

TRANSCRIPT

Page 1: Streamlining Workflows with Puppet Faces

PUPPET FACESStreamlining Workflows

Kelsey Hightower

Page 2: Streamlining Workflows with Puppet Faces

AgendaFirst World Problems

Puppet Faces

Familiar Faces

A New Face

Core Components

Why?

Page 3: Streamlining Workflows with Puppet Faces

puppet dashboard

Page 4: Streamlining Workflows with Puppet Faces

Puppet DashboardVisualize Your Infrastructure: Status, Graphs, and Reports

External Node Classifier (ENC)

Page 5: Streamlining Workflows with Puppet Faces
Page 6: Streamlining Workflows with Puppet Faces

Puppet DashboardVisualize Your Infrastructure: Status, Graphs, and Reports

External Node Classifier (ENC)

Page 7: Streamlining Workflows with Puppet Faces

manage parameters, groups and classes

Page 8: Streamlining Workflows with Puppet Faces

First World Problems

Page 9: Streamlining Workflows with Puppet Faces

First World ProblemsOne key/value pair at a time

Page 10: Streamlining Workflows with Puppet Faces

First World ProblemsOne key/value pair at a time

Time consuming

Page 11: Streamlining Workflows with Puppet Faces

First World ProblemsOne key/value pair at a time

Time consuming

Managing ENC data in dashboard could be better

Page 12: Streamlining Workflows with Puppet Faces

First World Problems

Page 13: Streamlining Workflows with Puppet Faces

First World ProblemsClick Chrome icon

Page 14: Streamlining Workflows with Puppet Faces

First World ProblemsClick Chrome icon

Click on Puppet Dashboard bookmark

Page 15: Streamlining Workflows with Puppet Faces

First World ProblemsClick Chrome icon

Click on Puppet Dashboard bookmark

Click on each system

Page 16: Streamlining Workflows with Puppet Faces

First World ProblemsClick Chrome icon

Click on Puppet Dashboard bookmark

Click on each system

Click edit

Page 17: Streamlining Workflows with Puppet Faces

First World ProblemsClick Chrome icon

Click on Puppet Dashboard bookmark

Click on each system

Click edit

Click add new parameter

Page 18: Streamlining Workflows with Puppet Faces

First World ProblemsClick Chrome icon

Click on Puppet Dashboard bookmark

Click on each system

Click edit

Click add new parameter

Click save

Page 19: Streamlining Workflows with Puppet Faces

First World ProblemsClick Chrome icon

Click on Puppet Dashboard bookmark

Click on each system

Click edit

Click add new parameter

Click save

Click on each group

Page 20: Streamlining Workflows with Puppet Faces

First World ProblemsClick Chrome icon

Click on Puppet Dashboard bookmark

Click on each system

Click edit

Click add new parameter

Click save

Click on each group

Click edit

Page 21: Streamlining Workflows with Puppet Faces

First World ProblemsClick Chrome icon

Click on Puppet Dashboard bookmark

Click on each system

Click edit

Click add new parameter

Click save

Click on each group

Click edit

Click some more.

Page 22: Streamlining Workflows with Puppet Faces

Lots of clicking!!

Page 23: Streamlining Workflows with Puppet Faces

Puppet?

Page 24: Streamlining Workflows with Puppet Faces

parameters: node: - "el6.puppetize.me": "domain": "puppetize.me"

group: - "webservers": "apache_version": "2.2.16"

Page 25: Streamlining Workflows with Puppet Faces

puppet cool-subcommand import data.yaml

Page 26: Streamlining Workflows with Puppet Faces

Puppet Faces

Page 27: Streamlining Workflows with Puppet Faces

What are Puppet Faces?

Page 28: Streamlining Workflows with Puppet Faces

What are Puppet Faces?API for extending existing Puppet functionality

Page 29: Streamlining Workflows with Puppet Faces

What are Puppet Faces?API for extending existing Puppet functionality

API for creating Puppet subcommands and actions

Page 30: Streamlining Workflows with Puppet Faces

Familiar Facescatalog

certificate

certificate_request

config

facts

file

man

node

report

resource

status

Page 31: Streamlining Workflows with Puppet Faces

catalog

Page 32: Streamlining Workflows with Puppet Faces

catalogpuppet catalog select puppet.testing.org package

Page 33: Streamlining Workflows with Puppet Faces

catalogpuppet catalog select puppet.testing.org package

Package[openssh-server]

Page 34: Streamlining Workflows with Puppet Faces

catalog

puppet catalog download

puppet catalog select puppet.testing.org package

Package[openssh-server]

Page 35: Streamlining Workflows with Puppet Faces

catalog

puppet catalog download

notice: Saved catalog for puppet.testing.org to yaml

puppet catalog select puppet.testing.org package

Package[openssh-server]

Page 36: Streamlining Workflows with Puppet Faces

catalog

puppet catalog download

notice: Saved catalog for puppet.testing.org to yaml

puppet catalog select puppet.testing.org package

Package[openssh-server]

puppet catalog apply

Page 37: Streamlining Workflows with Puppet Faces

catalog

puppet catalog download

notice: Saved catalog for puppet.testing.org to yaml

puppet catalog select puppet.testing.org package

Package[openssh-server]

puppet catalog apply

notice: Finished catalog run in 0.39 seconds"#<Puppet::Transaction::Report:0x98eafcc>"

Page 38: Streamlining Workflows with Puppet Faces

config

Page 39: Streamlining Workflows with Puppet Faces

configpuppet config print server --mode agent

Page 40: Streamlining Workflows with Puppet Faces

configpuppet config print server --mode agent

puppet.testing.org

Page 41: Streamlining Workflows with Puppet Faces

configpuppet config print server --mode agent

puppet.testing.org

puppet config print all --mode agent

Page 42: Streamlining Workflows with Puppet Faces

configpuppet config print server --mode agent

puppet.testing.org

puppet config print all --mode agent

allow_duplicate_certs = falsearchive_file_server = puppet.testing.orgarchive_files = falseasync_storeconfigs = falseauthconfig = /etc/puppet/namespaceauth.confautoflush = falseautosign = /etc/puppet/autosign.confbindaddress = ""bucketdir = /var/lib/puppet/bucket...

Page 43: Streamlining Workflows with Puppet Faces

certificate

Page 44: Streamlining Workflows with Puppet Faces

certificatepuppet certificate find puppet.testing.org --ca-location=remote

Page 45: Streamlining Workflows with Puppet Faces

certificatepuppet certificate find puppet.testing.org --ca-location=remote

-----BEGIN CERTIFICATE-----MIIClzCCAgCgAwIBAgIBBjANBgkqhkiG9w0BAQUFADAoMSYwJAYDVQQDDB1QdXBwZXQgQ0E6IHB1cHBldC50ZXN0aW5nLm9yZzAeFw0xMTA5MDcxNzE1MjJaFw0xNjA5MDUxNzE1MjJaMB0xGzAZBgNVBAMMEnB1cHBldC50ZXN0aW5nLm9yZzCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEA0C8WqEYaZiYRGb0mY1LFSEp7M3NIpugcmhJ1eZ9gck0gEtYrk2FetOqBqwF45df3FDXUvHKovcNaJeJ05Gn0XFrAZ8Y7IQsboX993Dd3d+7yq0T4gK1myjnizzqPaa/cgJrAtc1caByoxe1fYL1SJKnm+/u9z6YOT4OI8UtfYskCAwEAAaOB2zCB2DA4BglghkgBhvhCAQ0EKxYpUHVwcGV0IFJ1YnkvT3BlblNTTCBHZW5lcmF0ZWQgQ2VydGlmaWNhdGUwDAYDVR0TAQH/BAIwADAdBgNVHQ4EFgQUaBiSUyQXKLtAj+cNlcEAsVwjRNkwCwYDVR0PBAQDAgWgMCcGA1UdJQQgMB4GCCsGAQUFBwMBBggrBgEFBQcDAgYIKwYBBQUHAwQwOQYDVR0RBDIwMIIGcHVwcGV0ghJwdXBwZXQudGVzdGluZy5vcmeCEnB1cHBldC50ZXN0aW5nLm9yZzANBgkqhkiG9w0BAQUFAAOBgQBgOYHKMehXRba77I0zOLmnZMh0Y0HvyuSX843e++pXrje/+fCBIqvVai7wCrElLB6pdLsFYVyeLkONGRB6eGGeHr9yRWwSVhEPPySdh2uRER3M530JxCG+tkz4BNtnGGQB+wI12p8EL47axxP/OiCMGCdS8Xi21+FIg2/dwQnsPA==-----END CERTIFICATE-----

Page 46: Streamlining Workflows with Puppet Faces

resource

Page 47: Streamlining Workflows with Puppet Faces

resourcepuppet resource package telnet ensure=present

Page 48: Streamlining Workflows with Puppet Faces

resourcepuppet resource package telnet ensure=present

notice: /Package[telnet]/ensure: created

Page 49: Streamlining Workflows with Puppet Faces

resourcepuppet resource package telnet ensure=present

notice: /Package[telnet]/ensure: created

package { 'telnet': ensure => '0.17-36',}

Page 50: Streamlining Workflows with Puppet Faces

dashboard face

Page 51: Streamlining Workflows with Puppet Faces
Page 52: Streamlining Workflows with Puppet Faces

dashboard

Page 53: Streamlining Workflows with Puppet Faces

dashboardQuery Puppet Dashboard

Page 54: Streamlining Workflows with Puppet Faces

dashboardQuery Puppet Dashboard

Import/Export data

Page 55: Streamlining Workflows with Puppet Faces

How?

Page 56: Streamlining Workflows with Puppet Faces

Programming Motherfu*ker

Page 57: Streamlining Workflows with Puppet Faces

Project LayoutLICENSE

README

lib/puppet/application/dashboard.rb

lib/puppet/face/dashboard.rb

lib/puppet/face/dashboard/*.rb

Page 58: Streamlining Workflows with Puppet Faces

Core Componentsapplication

options

arguments

actions

Page 59: Streamlining Workflows with Puppet Faces

Only limited by your imagination.

Page 60: Streamlining Workflows with Puppet Faces

Only limited by your imagination.

Dragon Face

Page 61: Streamlining Workflows with Puppet Faces

puppet dashboard import data.yaml

Page 62: Streamlining Workflows with Puppet Faces

puppet dashboard import data.yaml

application

Page 63: Streamlining Workflows with Puppet Faces

Applicationcopyright

license

summary

description

short_description

action

Page 64: Streamlining Workflows with Puppet Faces

Application Class

require 'puppet/face'require 'puppet/application/face_base'

class Puppet::Application::Dashboard < Puppet::Application::FaceBaseend

dashboard-puppet-face/lib/puppet/application/dashboard.rb

Page 65: Streamlining Workflows with Puppet Faces

Application Class

require 'puppet/face'require 'puppet/application/face_base'

class Puppet::Application::Dashboard < Puppet::Application::FaceBaseend

dashboard-puppet-face/lib/puppet/application/dashboard.rb

inherit FaceBase

Page 66: Streamlining Workflows with Puppet Faces

Applicationpuppet-dashboard-face/lib/puppet/face/dashboard.rb

require 'puppet'require 'puppet/face'

Puppet::Face.define(:dashboard, '0.0.1') do summary "Puppet Dashboard Integration" copyright "Kelsey Hightower", 2011 license "Apache 2 license" description "Puppet Dashboard Integration"end

Page 67: Streamlining Workflows with Puppet Faces

Applicationpuppet-dashboard-face/lib/puppet/face/dashboard.rb

require 'puppet'require 'puppet/face'

Puppet::Face.define(:dashboard, '0.0.1') do summary "Puppet Dashboard Integration" copyright "Kelsey Hightower", 2011 license "Apache 2 license" description "Puppet Dashboard Integration"end

subcommand

Page 68: Streamlining Workflows with Puppet Faces

Applicationpuppet-dashboard-face/lib/puppet/face/dashboard.rb

require 'puppet'require 'puppet/face'

Puppet::Face.define(:dashboard, '0.0.1') do summary "Puppet Dashboard Integration" copyright "Kelsey Hightower", 2011 license "Apache 2 license" description "Puppet Dashboard Integration"end

api version

Page 69: Streamlining Workflows with Puppet Faces

puppet dashboard import data.yaml\--adapter=mysql --host=127.0.0.1

Page 70: Streamlining Workflows with Puppet Faces

puppet dashboard import data.yaml\--adapter=mysql --host=127.0.0.1

options

Page 71: Streamlining Workflows with Puppet Faces

Optionsadapter

username

password

host

database

Page 72: Streamlining Workflows with Puppet Faces

Optionspuppet-dashboard-face/lib/puppet/face/dashboard.rb

require 'puppet'require 'puppet/face'

Puppet::Face.define(:dashboard, '0.0.1') do ... option "--adapter ADAPTER" do summary "Active Record database adapter" description <<-'EOT' The adapter for to use when accessing the Puppet Dashboard database. EOT end ...end

Page 73: Streamlining Workflows with Puppet Faces

Optionspuppet-dashboard-face/lib/puppet/face/dashboard.rb

require 'puppet'require 'puppet/face'

Puppet::Face.define(:dashboard, '0.0.1') do ... option "--adapter ADAPTER" do summary "Active Record database adapter" description <<-'EOT' The adapter for to use when accessing the Puppet Dashboard database. EOT end ...end

define options

Page 74: Streamlining Workflows with Puppet Faces

puppet dashboard import data.yaml

Page 75: Streamlining Workflows with Puppet Faces

puppet dashboard import data.yaml

arguments

Page 76: Streamlining Workflows with Puppet Faces

ArgumentsFaces can accept positional arguments

Page 77: Streamlining Workflows with Puppet Faces

Argumentspuppet-dashboard-face/lib/puppet/face/dashboard/import.rb

Puppet::Face.define(:dashboard, '0.0.1') do action :import do summary "Import ENC paramters" arguments "<data>" description <<-'EOT' Bulk import external nodes configuration data into dashboard EOT endend

Page 78: Streamlining Workflows with Puppet Faces

puppet dashboard import data.yaml

Page 79: Streamlining Workflows with Puppet Faces

puppet dashboard import data.yaml

action

Page 80: Streamlining Workflows with Puppet Faces

Actionssummary

arguments

returns

description

notes

examples

when_invoked

when_rendering

Page 81: Streamlining Workflows with Puppet Faces

Actionspuppet-dashboard-face/lib/puppet/face/dashboard/import.rb

Puppet::Face.define(:dashboard, '0.0.1') do action :import do summary "Import ENC paramters" arguments "<data>" description <<-'EOT' Bulk import external nodes configuration data into dashboard EOT

when_invoked do |data, options| ... end endend

Page 82: Streamlining Workflows with Puppet Faces

Actionspuppet-dashboard-face/lib/puppet/face/dashboard/import.rb

Puppet::Face.define(:dashboard, '0.0.1') do action :import do summary "Import ENC paramters" arguments "<data>" description <<-'EOT' Bulk import external nodes configuration data into dashboard EOT

when_invoked do |data, options| ... end endend

Action

Page 83: Streamlining Workflows with Puppet Faces

Actionspuppet-dashboard-face/lib/puppet/face/dashboard/import.rb

Puppet::Face.define(:dashboard, '0.0.1') do action :import do summary "Import ENC paramters" arguments "<data>" description <<-'EOT' Bulk import external nodes configuration data into dashboard EOT

when_invoked do |data, options| ... end endend This is where the

works gets done.

Page 84: Streamlining Workflows with Puppet Faces

Almost ready to solve this problem.

Page 85: Streamlining Workflows with Puppet Faces

Deploying our Face

Page 86: Streamlining Workflows with Puppet Faces

Deployment

Page 87: Streamlining Workflows with Puppet Faces

Deploymentrsync -av puppet-dashboard-face/lib/puppet/ \/opt/ruby/lib/ruby/gems/1.8/gems/puppet-2.7.3/lib/puppet/

Page 88: Streamlining Workflows with Puppet Faces

Deploymentrsync -av puppet-dashboard-face/lib/puppet/ \/opt/ruby/lib/ruby/gems/1.8/gems/puppet-2.7.3/lib/puppet/

sending incremental file list./application/application/dashboard.rbface/face/dashboard.rbface/dashboard/face/dashboard/import.rbface/dashboard/list.rbface/dashboard/models.rbface/dashboard/report.rbface/dashboard/search.rb

sent 9069 bytes received 160 bytes 18458.00 bytes/sectotal size is 8546 speedup is 0.93

Page 89: Streamlining Workflows with Puppet Faces

Deployment

Page 90: Streamlining Workflows with Puppet Faces

Deploymentpuppet help

Page 91: Streamlining Workflows with Puppet Faces

Deploymentpuppet help

Usage: puppet <subcommand> [options] <action> [options]

Available subcommands, from Puppet Faces: catalog Compile, save, view, and convert catalogs. facts Retrieve and store facts. help Display Puppet help. dashboard Puppet Dashboard Integration. man Display Puppet manual pages. node View and manage node definitions. parser Interact directly with the parser.

Page 92: Streamlining Workflows with Puppet Faces

Help

Page 93: Streamlining Workflows with Puppet Faces

Helppuppet help dashboard

Page 94: Streamlining Workflows with Puppet Faces

Helppuppet help dashboard

USAGE: puppet dashboard <action> [--host HOST] ...

Interact with Puppet Dashboard

OPTIONS: ... --adapter ADAPTER - Active Record Database Adapter --host HOST - Database Hostname

ACTIONS: import Import data into Puppet Dashboard.

See 'puppet man dashboard' or 'man puppet-dashboard' for full help.

Page 95: Streamlining Workflows with Puppet Faces

RTFM

Page 96: Streamlining Workflows with Puppet Faces

Read The Face Manual

Page 97: Streamlining Workflows with Puppet Faces

Read The Face Manualpuppet man dashboard

Page 98: Streamlining Workflows with Puppet Faces

Read The Face Manualpuppet man dashboard

PUPPET-DASHBOARD(8) Puppet Manual PUPPET-DASHBOARD(8)

NAME puppet-dashboard - Interact with Puppet Dashboard

SYNOPSIS puppet dashboard action [--adapter ADAPTER] [--database DATBASE] [--username USER] [--password PASSWORD] [--host HOST]

OPTIONS Note that any configuration parameter that's valid in the configuration file is also a valid long argument, although it may or may not be rele- vant to the present action. For example, server is a valid configura- tion parameter, so you can specify --server <servername> as an argu- ment.

Page 99: Streamlining Workflows with Puppet Faces

Putting it all together

Page 100: Streamlining Workflows with Puppet Faces

parameters: node: - "master.lab.org": "domain": "puppetize.me"

group: - "webservers": "apache_version": "2.2.16"

Page 101: Streamlining Workflows with Puppet Faces

puppet dashboard import data.yaml

Page 102: Streamlining Workflows with Puppet Faces

Problem solved!

Page 103: Streamlining Workflows with Puppet Faces

Better for the environment

Page 104: Streamlining Workflows with Puppet Faces

75% less batteries

Page 105: Streamlining Workflows with Puppet Faces
Page 106: Streamlining Workflows with Puppet Faces

Why Puppet Faces?

Page 107: Streamlining Workflows with Puppet Faces

Consolidation

Page 108: Streamlining Workflows with Puppet Faces

Consolidation/usr/sbin/dashboard_importer

Page 109: Streamlining Workflows with Puppet Faces

Consolidation/usr/sbin/dashboard_importer

/usr/sbin/dashboard_importer.bak

Page 110: Streamlining Workflows with Puppet Faces

Consolidation/usr/sbin/dashboard_importer

/usr/sbin/dashboard_importer.bak

/usr/sbin/dashboardImporter

Page 111: Streamlining Workflows with Puppet Faces

Consolidation/usr/sbin/dashboard_importer

/usr/sbin/dashboard_importer.bak

/usr/sbin/dashboardImporter

/usr/sbin/dashboard_importer.new

Page 112: Streamlining Workflows with Puppet Faces

Consolidation/usr/sbin/dashboard_importer

/usr/sbin/dashboard_importer.bak

/usr/sbin/dashboardImporter

/usr/sbin/dashboard_importer.new

puppet dashboard importer

Page 113: Streamlining Workflows with Puppet Faces

Free Documentationpuppet man dashboard

puppet help dashboard

Page 114: Streamlining Workflows with Puppet Faces

Free Ruby API

Page 115: Streamlining Workflows with Puppet Faces

Free Ruby APIirb

Page 116: Streamlining Workflows with Puppet Faces

Free Ruby APIirb

irb> require 'rubygems'

Page 117: Streamlining Workflows with Puppet Faces

Free Ruby APIirb

irb> require 'rubygems'irb> require 'puppet/face'

Page 118: Streamlining Workflows with Puppet Faces

Free Ruby APIirb

irb> require 'rubygems'irb> require 'puppet/face'irb> arguments = '/tmp/data.yaml'

Page 119: Streamlining Workflows with Puppet Faces

Free Ruby APIirb

irb> require 'rubygems'irb> require 'puppet/face'irb> arguments = '/tmp/data.yaml'irb> options = {:adapter => 'mysql', :password => ..

Page 120: Streamlining Workflows with Puppet Faces

Free Ruby APIirb

irb> require 'rubygems'irb> require 'puppet/face'irb> arguments = '/tmp/data.yaml'irb> options = {:adapter => 'mysql', :password => ..irb> dashboard = Puppet::Face[:dashboard,'0.0.1']

Page 121: Streamlining Workflows with Puppet Faces

Free Ruby APIirb

irb> require 'rubygems'irb> require 'puppet/face'irb> arguments = '/tmp/data.yaml'irb> options = {:adapter => 'mysql', :password => ..irb> dashboard = Puppet::Face[:dashboard,'0.0.1']irb> dashboard.import(arguments, options)

Page 122: Streamlining Workflows with Puppet Faces

Free Ruby APIirb

irb> require 'rubygems'irb> require 'puppet/face'irb> arguments = '/tmp/data.yaml'irb> options = {:adapter => 'mysql', :password => ..irb> dashboard = Puppet::Face[:dashboard,'0.0.1']irb> dashboard.import(arguments, options)

puppet dashboard import /tmp/data.yaml --adapter=mysql ...

Page 123: Streamlining Workflows with Puppet Faces

Good Investment

Page 124: Streamlining Workflows with Puppet Faces

The FutureReference custom parameters from puppet.conf

Expose Faces to external REST API

Page 125: Streamlining Workflows with Puppet Faces

khightower/puppet-dashboard-face

github

Page 126: Streamlining Workflows with Puppet Faces

@kelseyhightowertwitter

Page 127: Streamlining Workflows with Puppet Faces

puppetize.meweb

Page 128: Streamlining Workflows with Puppet Faces

Questions?