50
Configuring Nagios with Chef Bryan McLellan Technical Program Manager, Open Source [email protected] / @btmspox Tuesday, September 25, 12

Nagios Conference 2012 - Bryan McLellan - Using Nagios With Chef

  • Upload
    nagios

  • View
    757

  • Download
    0

Embed Size (px)

DESCRIPTION

Bryan McLellan's presentation on using Nagios with chef. The presentation was given during the Nagios World Conference North America held Sept 25-28th, 2012 in Saint Paul, MN. For more information on the conference (including photos and videos), visit: http://go.nagios.com/nwcna

Citation preview

Page 1: Nagios Conference 2012 - Bryan McLellan - Using Nagios With Chef

Configuring Nagios with ChefBryan McLellanTechnical Program Manager, Open [email protected] / @btmspox

Tuesday, September 25, 12

Page 2: Nagios Conference 2012 - Bryan McLellan - Using Nagios With Chef

Overview

• Who am I?

• Why automation

• Introduction to Chef

• Nagios Demo

• Questions

Tuesday, September 25, 12

Page 3: Nagios Conference 2012 - Bryan McLellan - Using Nagios With Chef

Who am I?

• ChefEarly developer, user, pundit

• 10+ years in Systems AdministrationComputer repair, ISPs, Corporate IT,Web operations

• Event Logistics VolunteerTraffic Control, Parking, Communications, Networking, Emergency Management

• Hacker-OperatorTrucks, Bikes, Radios, Tractors

Tuesday, September 25, 12

Page 4: Nagios Conference 2012 - Bryan McLellan - Using Nagios With Chef

How did we get here?

Bare Metal Deployment

Tuesday, September 25, 12

Page 5: Nagios Conference 2012 - Bryan McLellan - Using Nagios With Chef

How did we get here?

Bare Metal Deployment

• Purchasing

Tuesday, September 25, 12

Page 6: Nagios Conference 2012 - Bryan McLellan - Using Nagios With Chef

How did we get here?

Bare Metal Deployment

• Purchasing

• Vendor build

Tuesday, September 25, 12

Page 7: Nagios Conference 2012 - Bryan McLellan - Using Nagios With Chef

How did we get here?

Bare Metal Deployment

• Purchasing

• Vendor build

• Delivery

Tuesday, September 25, 12

Page 8: Nagios Conference 2012 - Bryan McLellan - Using Nagios With Chef

How did we get here?

Bare Metal Deployment

• Purchasing

• Vendor build

• Delivery

• Installation

Tuesday, September 25, 12

Page 9: Nagios Conference 2012 - Bryan McLellan - Using Nagios With Chef

How did we get here?

Bare Metal Deployment

• Purchasing

• Vendor build

• Delivery

• Installation

• OS deployment

Tuesday, September 25, 12

Page 10: Nagios Conference 2012 - Bryan McLellan - Using Nagios With Chef

How did we get here?

Bare Metal Deployment

• Purchasing

• Vendor build

• Delivery

• Installation

• OS deployment

• Application deployment

Tuesday, September 25, 12

Page 11: Nagios Conference 2012 - Bryan McLellan - Using Nagios With Chef

How did we get here?

Bare Metal Deployment

• Purchasing

• Vendor build

• Delivery

• Installation

• OS deployment

• Application deployment

Weeks?

Tuesday, September 25, 12

Page 12: Nagios Conference 2012 - Bryan McLellan - Using Nagios With Chef

How did we get here?

Cloud Deployment

• Purchasing

• Vendor build

• Delivery

• Installation

• OS deployment

• Application deployment

Nearly immediate

Tuesday, September 25, 12

Page 13: Nagios Conference 2012 - Bryan McLellan - Using Nagios With Chef

How did we get here?

Cloud Deployment

• Purchasing

• Vendor build

• Delivery

• Installation

• OS deployment

• Application deployment

Nearly immediate

Must be fast

Tuesday, September 25, 12

Page 14: Nagios Conference 2012 - Bryan McLellan - Using Nagios With Chef

Why automate?

Good Reasons:

• More agility and faster scalability

• Improved infrastructure documentation

• Better disaster recovery

Tuesday, September 25, 12

Page 15: Nagios Conference 2012 - Bryan McLellan - Using Nagios With Chef

Why automate?

Good Reasons:

• More agility and faster scalability

• Improved infrastructure documentation

• Better disaster recovery

Really Good Reasons:

• Spend less time on monotonous tasks

• Spend more time solving interesting problems

Tuesday, September 25, 12

Page 16: Nagios Conference 2012 - Bryan McLellan - Using Nagios With Chef

Chef Principles

Tuesday, September 25, 12

Page 17: Nagios Conference 2012 - Bryan McLellan - Using Nagios With Chef

Chef Principles

• Idempotent

Tuesday, September 25, 12

Page 18: Nagios Conference 2012 - Bryan McLellan - Using Nagios With Chef

Chef Principles

• Idempotent

• Reasonable

Tuesday, September 25, 12

Page 19: Nagios Conference 2012 - Bryan McLellan - Using Nagios With Chef

Chef Principles

• Idempotent

• Reasonable

• Primitives

Tuesday, September 25, 12

Page 20: Nagios Conference 2012 - Bryan McLellan - Using Nagios With Chef

Chef Principles

• Idempotent

• Reasonable

• Primitives

• Scalable

Tuesday, September 25, 12

Page 21: Nagios Conference 2012 - Bryan McLellan - Using Nagios With Chef

Chef Principles

• Idempotent

• Reasonable

• Primitives

• Scalable

• Hackable

Tuesday, September 25, 12

Page 22: Nagios Conference 2012 - Bryan McLellan - Using Nagios With Chef

Chef Principles

• Idempotent

• Reasonable

• Primitives

• Scalable

• Hackable

• Shareable

Tuesday, September 25, 12

Page 23: Nagios Conference 2012 - Bryan McLellan - Using Nagios With Chef

What is Chef?

• Configuration management language

• Systems integration framework

• API for your infrastructure

http://www.flickr.com/photos/morville/3220961040/

Tuesday, September 25, 12

Page 24: Nagios Conference 2012 - Bryan McLellan - Using Nagios With Chef

Application Programming Interface

Give me an API or give me death.

-- Andrew Clay Shafer (@littleidea)

The Meatcloud Manifesto

Tuesday, September 25, 12

Page 25: Nagios Conference 2012 - Bryan McLellan - Using Nagios With Chef

Chef Basics

Chef manages Nodes

Tuesday, September 25, 12

Page 26: Nagios Conference 2012 - Bryan McLellan - Using Nagios With Chef

Chef Basics

Chef manages Nodes

Nodes have Attributes

Tuesday, September 25, 12

Page 27: Nagios Conference 2012 - Bryan McLellan - Using Nagios With Chef

Chef Basics

Chef manages Nodes

Nodes have Attributes

Users and Nodes authenticate as Clients

Tuesday, September 25, 12

Page 28: Nagios Conference 2012 - Bryan McLellan - Using Nagios With Chef

Chef Basics

Chef manages Nodes

Nodes have Attributes

Users and Nodes authenticate as Clients

Cookbooks contain Recipes

Tuesday, September 25, 12

Page 29: Nagios Conference 2012 - Bryan McLellan - Using Nagios With Chef

Chef Basics

Chef manages Nodes

Nodes have Attributes

Users and Nodes authenticate as Clients

Cookbooks contain Recipes

Each node has a Run List

Tuesday, September 25, 12

Page 30: Nagios Conference 2012 - Bryan McLellan - Using Nagios With Chef

Chef Basics

Chef manages Nodes

Nodes have Attributes

Users and Nodes authenticate as Clients

Cookbooks contain Recipes

Each node has a Run List

A Run List is a list of Recipes to run

Tuesday, September 25, 12

Page 31: Nagios Conference 2012 - Bryan McLellan - Using Nagios With Chef

Chef Basics

Chef manages Nodes

Nodes have Attributes

Users and Nodes authenticate as Clients

Cookbooks contain Recipes

Each node has a Run List

A Run List is a list of Recipes to run

Recipes can be grouped in a Role

Tuesday, September 25, 12

Page 32: Nagios Conference 2012 - Bryan McLellan - Using Nagios With Chef

Chef Basics

Chef manages Nodes

Nodes have Attributes

Users and Nodes authenticate as Clients

Cookbooks contain Recipes

Each node has a Run List

A Run List is a list of Recipes to run

Recipes can be grouped in a Role

Roles can also be added to a Run List

Tuesday, September 25, 12

Page 33: Nagios Conference 2012 - Bryan McLellan - Using Nagios With Chef

Chef Basics

Chef manages Nodes

Nodes have Attributes

Users and Nodes authenticate as Clients

Cookbooks contain Recipes

Each node has a Run List

A Run List is a list of Recipes to run

Recipes can be grouped in a Role

Roles can also be added to a Run List

Nodes can be in Environments

Tuesday, September 25, 12

Page 34: Nagios Conference 2012 - Bryan McLellan - Using Nagios With Chef

Chef Basics

Chef manages Nodes

Nodes have Attributes

Users and Nodes authenticate as Clients

Cookbooks contain Recipes

Each node has a Run List

A Run List is a list of Recipes to run

Recipes can be grouped in a Role

Roles can also be added to a Run List

Nodes can be in Environments

Data bags are... bags of data.

Tuesday, September 25, 12

Page 35: Nagios Conference 2012 - Bryan McLellan - Using Nagios With Chef

Chef Basics Visualized

node: srv03run_list: “role[db_server]”

role: web_serverrun_list: [“recipe[apache2]”, “recipe[php]” ]

role: db_serverrun_list: [ “recipe[mysql]”, “recipe[nfs]” ]

node: srv01run_list: “role[web_server]”

node: srv02run_list: “role[web_server]”

client: srv03client: srv01 client: srv02

Tuesday, September 25, 12

Page 36: Nagios Conference 2012 - Bryan McLellan - Using Nagios With Chef

chef-shellknife

Chef Stacks

chef-client

Open Source Hosted Chef Private Chef

API

chef-solo

Tuesday, September 25, 12

Page 37: Nagios Conference 2012 - Bryan McLellan - Using Nagios With Chef

Chef 10 Open Source Architecture

Chef Expander

Tuesday, September 25, 12

Page 38: Nagios Conference 2012 - Bryan McLellan - Using Nagios With Chef

Resources

• A Resource is something you manageservice, package, file, user, execute, git

Tuesday, September 25, 12

Page 39: Nagios Conference 2012 - Bryan McLellan - Using Nagios With Chef

Resources

• A Resource is something you manageservice, package, file, user, execute, git

• Resources have actionsstart, install, create, deploy

• Resources can notify of other resources

Tuesday, September 25, 12

Page 40: Nagios Conference 2012 - Bryan McLellan - Using Nagios With Chef

Resources

• A Resource is something you manageservice, package, file, user, execute, git

• Resources have actionsstart, install, create, deploy

• Resources can notify of other resources

cookbook_file “/etc/apache2/apache2.conf” do source “apache2.conf” owner “root” group “root” mode 0644 notifies :restart, “service[apache2]”end

Tuesday, September 25, 12

Page 41: Nagios Conference 2012 - Bryan McLellan - Using Nagios With Chef

Providers

• A Provider performs the actions specified by the resource

Tuesday, September 25, 12

Page 42: Nagios Conference 2012 - Bryan McLellan - Using Nagios With Chef

Providers

• A Provider performs the actions specified by the resource

• Each Resource can have multiple providerspackage: apt, yum, macports...service: upstart, windows, systemd...

Tuesday, September 25, 12

Page 43: Nagios Conference 2012 - Bryan McLellan - Using Nagios With Chef

Providers

• A Provider performs the actions specified by the resource

• Each Resource can have multiple providerspackage: apt, yum, macports...service: upstart, windows, systemd...

• Each platform (OS) has default Providers that can be overridden

package “sudo” do provider Chef::Provider::Package::Yum action :installend

Tuesday, September 25, 12

Page 44: Nagios Conference 2012 - Bryan McLellan - Using Nagios With Chef

A basic recipe

package “apache2” do action :installend

Tuesday, September 25, 12

Page 45: Nagios Conference 2012 - Bryan McLellan - Using Nagios With Chef

A basic recipe

package “apache2” do action :installend

service “apache2” do action :enableend

Tuesday, September 25, 12

Page 46: Nagios Conference 2012 - Bryan McLellan - Using Nagios With Chef

A basic recipe

package “apache2” do action :installend

service “apache2” do action :enableend

cookbook_file “/etc/apache2/apache2.conf” do source “apache2.conf” owner “root” group “root” mode 0644end

Tuesday, September 25, 12

Page 47: Nagios Conference 2012 - Bryan McLellan - Using Nagios With Chef

A basic recipe

package “apache2” do action :installend

service “apache2” do action :enableend

cookbook_file “/etc/apache2/apache2.conf” do source “apache2.conf” owner “root” group “root” mode 0644end

service “apache2” do action :startend

Tuesday, September 25, 12

Page 48: Nagios Conference 2012 - Bryan McLellan - Using Nagios With Chef

A basic recipe

package “apache2” do action :installend

service “apache2” do action :enable supports [ :restart, :reload, :status ]end

cookbook_file “/etc/apache2/apache2.conf” do source “apache2.conf” owner “root” group “root” mode 0644 notifies :restart, “service[apache2]”end

service “apache2” do action :startend

Tuesday, September 25, 12

Page 49: Nagios Conference 2012 - Bryan McLellan - Using Nagios With Chef

Nagios Demo• Download server cookbooks• Install server• Create fake nodes• Update server

Tuesday, September 25, 12

Page 50: Nagios Conference 2012 - Bryan McLellan - Using Nagios With Chef

Questions?

There is lots more to learn about Chef at

http://wiki.opscode.com

Tuesday, September 25, 12