59
Puppet for Sysadmins PuppetCamp 2013 - Sydney

Puppet for SysAdmins

Embed Size (px)

DESCRIPTION

Stephen Wallace at Puppet Camp Sydney 2013

Citation preview

Page 1: Puppet for SysAdmins

Puppetfor Sysadmins

PuppetCamp 2013 - Sydney

Page 2: Puppet for SysAdmins

Och Aye The Noo!(oh yes, right now!)

Stephen Wallace

20 years experience

Predom *nix / sysadmin background

Senior management - teams up to 20

Large heavily integrated systems

Health, Online Gaming, Recruitment

ICE Systems 18 mths....one of the Puppet go to guys

[email protected]

Linkedin: http://au.linkedin.com/in/stephenwallace

Page 3: Puppet for SysAdmins

Who am I talking to?

� Sysadmin

� Operations management

� ...and the Puppet newbs

Page 4: Puppet for SysAdmins

Why should I listen?

Page 5: Puppet for SysAdmins

Spot the challenge!

An extract from my Linkedin profile(au.linkedin.com/in/stephenwallace)

� Harvey Nash, Database Administrator, London

� Hays Personnel Services, IT Manager ANZ, Sydney

� Saffron Consulting, Unix/Linux Consultant, Sydney

� Business Systems Manager, Corporate Express, Sydney

� Unix Services Manager, NHS, Glasgow

� Technical Operations Manager, Casino.com, Gibraltar

� IT Operations Manager, Healthecare Aust, Sydney

� Solution Architect, ICE Systems, Sydney

Not a whisper of dev/proggie anywhere!

Page 6: Puppet for SysAdmins

Puppet...for

Non-proggies

PuppetCamp 2013 - Sydney

Page 7: Puppet for SysAdmins

Begin with the end in mind

“Would you tell me, please, which way I ought to go from here?”

“That depends a good deal on where you want to get to“, said the cat.

“I don’t much care where”, said Alice.

“Then it doesn’t matter which way you go”, said the cat.

(Alice's Adventures in Wonderland, chapter 6)

...the importance of goals

Page 8: Puppet for SysAdmins

Goals for everybody?

Page 9: Puppet for SysAdmins

Goals for the talkers?(aka ops management...)

� Availability

� Scalability

� Supportability

� Predictability

� Agility

� KeepTheCostsDownAbility...

� Smiling end users

� …and Cloudability

Page 10: Puppet for SysAdmins

Goals for doers?(aka sysadmins...)

� Predictable / stable infrastructure

� Reusable wins.....everybody listening?

� Fix stuff once

� Reduce support workload, so can finally get to that more interesting project stuff!

� Monitoring....that someone else maintains :)

� Documentation...ditto

� Smiling end users…resulting in...

� Weekends / sleep

� Pub by 5 (past 4 preferably)

� Spot the cuttlefish!

Page 11: Puppet for SysAdmins

Research-CentricAcademic Institution

� Sysadmin lead initiative

� Small team

� No opex budget

� Increasing number of users / power users

� Provisioning demands increasing

� Diversity of platform support requirements

� Also, legacy *nix env, with people based SPOF

� Unique huh? Didn't think so...

Page 12: Puppet for SysAdmins

Threat or an opp?

� Dev lead initiatives

� Publishing/media company – Window + Linux web stack. One of the biggest website in ANZ. Production.

� Insurance brokerage – current project.

� Ecommerce – Small team of developers. Using Puppet/AWS to spin up and tear down on demand. Production.

Page 13: Puppet for SysAdmins

What I did NOT need

Puppeteer skills Neckbeard

Apple Macbook

Page 14: Puppet for SysAdmins

What I DID need

• A paradigm shift, and a willingness to learn a few new tricks

ALSO…

Willingness to learn

Willingness to collaborate

Page 15: Puppet for SysAdmins

Times are a Changin'

� We used to receive hardware, rack n stack, folder of CDs for each operating system

� Pass over to the apps team

� Pass over to the database chaps

� Make sure that the monitoring is configured

� Draw some diagrams

� Pass to testing

� Progress through change management

Page 16: Puppet for SysAdmins

Nowadaze…

Launch the hyperviser or AWS Management Console, and click a button to spin up 1 or 1001 new nodes via templates.

Opportunity, or threat?

People are people....carefully does it

Page 17: Puppet for SysAdmins

Initial reaction to the word...

“Devops”...

The objection is rarely the objection!

Long live the onion!

Page 18: Puppet for SysAdmins

The Challenges & The Tools– aka “the useful stuff”

“We're not proggies.....we're sys admins!”

Keep Calm, and Carry On

Page 19: Puppet for SysAdmins

“Proggie syntax is WAY to hard...”

Ops boys and girls love scripting...right?

...especially when maintaining more than a handful of boxes

...its just a different, and not hugely difficult scripting language

...with Puppet Enterprise, it can be GUI driven

Page 20: Puppet for SysAdmins

Puppet can write Puppet code!

� puppet resource user...handy!

� puppet resource - types (lots of fun for all the family)

� ...and there's lots of “inspirational” stuff from the Forge ( http://forge.puppetlabs.com )!

� puppet module search mysql (gem install puppet-module)

Page 21: Puppet for SysAdmins

Native tools for syntax checking

puppet parser validate blah.pp

Page 22: Puppet for SysAdmins

Syntax Highlighting Tools

Put a bit of colour in your life...

vim-puppet

syntastic - similar

Page 23: Puppet for SysAdmins

There will still be a few sceptics

Page 24: Puppet for SysAdmins

We're gonna need a bigger boat

�Have a look! Self contained.

�Syntax examples with mouseover

�Autocorrects stuff!

� Integrates with source control

� Integrates into CI

� Integrates with the Forge!

� Geppetto

� IDE?

Page 25: Puppet for SysAdmins

A question of style?

We've all been there....your old sysadminleaves...and the newb arrives to investigate the scripts...AAAARARRRRGGH

Puppet Lint!

Page 26: Puppet for SysAdmins

Finding this all a bit testing?

Rspec-puppet - why test your modules, using yet another language?

How do I test that my new apache module will...create the following file resource:

/etc/apache2/sites-available/blah file

….when run on a Debian host?

Check it out...http://rspec-puppet.com/

Page 27: Puppet for SysAdmins

Maybe you didn't hear me

“We're not proggies

...we're sys admins!”

Page 28: Puppet for SysAdmins

“Whats wrong with flat files and dirs”

Nothing...Puppet works like that out of the box!

Hiera!

Not actually a Scandinavian greeting

Page 29: Puppet for SysAdmins

Hiera

� How can it benefit the ops crowd?

� A simple pluggable, hierarchical database

� Included with Puppet Enterprise, gem install for opensource

� Allows data to be separated from code

� Cleaner, more supportable manifests

Page 30: Puppet for SysAdmins

How does Hiera work?

HTTP VS APACHE2?

hiera.conf…you know conf files...right?!

:hierarchy:

- nodes/%{fqdn}

- %{operatingsystem}

- common

:backends: - yaml

:yaml:

:datadir: '/etc/puppetlabs/hieradata'

root@hpmini:~# facter operatingsystem

Ubuntu

root@hpmini:/etc/puppetlabs/hieradata/Ubuntu# cat common.yaml

webserver: apache2

Page 31: Puppet for SysAdmins

Why Hiera?

Good question!

Either have lengthy case statements...

Page 32: Puppet for SysAdmins

Complex thingocentos, redhat, oel, oraclelinux, linux: {

$supported = true

$webserver = [ "apache2" ]

$svc_name = "apache2"

$config = "/etc/apache2/httpd.conf"

if $::operatingsystemrelease =~ /^5/ {

$config_tpl = 'httpd.conf.el.erb'

} elsif $::operatingsystemrelease =~ /^6/ {

$config_tpl = 'httpd.conf.el6.erb'

} else {

fail("the webserver module doesn't know what template to use for your ${::oper

Page 33: Puppet for SysAdmins

...or you can have this

root@hpmini:/etc/puppetlabs/hieradata/Ubuntu# cat common.yaml

webserver: apache2

$webserver = hiera('webserver','httpd')

if $webserver != 'nil' {

package { $webserver:

ensure => present

}

hiera.conf - %{CustomFact-Environment}/common

Page 34: Puppet for SysAdmins

Augeus! Love those conf files...Configuration editing tool. It parses configuration files in their native formats and transforms them into a tree. Configuration changes are made by manipulating this tree and saving it back into native config files.

$defaultrunlevel = hiera('defaultrunlevel','3')

augeas { "runlevel":

context => "/files/etc/inittab",

changes => ["set id/runlevels ${defaultrunlevel}",

],

}

root@hpmini:/etc/puppetlabs/hieradata/production# grepdefaultrunlevel common.yaml

defaultrunlevel: 42

Page 35: Puppet for SysAdmins

Ruby? Sounds Scary

There's no place like 127.0.0.1...

Page 36: Puppet for SysAdmins

Ruby – Not that scary

�Deep breath...

�yum install blah.rpm (familiar?)

�apt-get install stuff

� ...gem install puppet-lint (!)

Page 37: Puppet for SysAdmins

But wait! There's more...

Cheatsheets! http://docs.puppetlabs.com

Provisioning:

Foreman (libvirt, EC2, RHEV)

Vagrant (Oracle Virtualbox)

...and now Razor (EMC). Early days, but growing popularity

Puppet Cloud Provisioner (AWS & VMWare)

Page 38: Puppet for SysAdmins

Version Control

� ...not just for proggies!

� git very popular. github very useful.

� Stash growing in popularity

� ...Aussie Aussie Aussie!

� ...Handy for sysadmins' shell scripts as well!

Page 39: Puppet for SysAdmins

But we're an enterprise shop

� ...Puppet's not quite there yet, Shirley?

Client side

�Ruby brush n scrub up. Load reduced.

�All major Linux flavours

�Solaris

�Select legacy o/s, Windows included ;)

Page 40: Puppet for SysAdmins

Puppet Server Side Grown Up

� PuppetDB – also with an API into Puppet Inventory Service.

� Ability to feed CMDB with most up to date facts

� Phusion Passenger

� Enterprise app server for Ruby

� ActiveMQ

� Enterprise message broker

� REST API

Page 41: Puppet for SysAdmins

PE also includes MCollective

How can I...

See how many of my machines are running RHEL 6.1?

See how many are running a particular release of a software package?

Monitor all of my servers for a resource level?

Mcollective can help manage, monitor, control Puppet, collect performance and inventory data...so...so...

Page 42: Puppet for SysAdmins

But but but

I've been using vi, shell scripts, and port 22 without mercy for years!

....my father did the same....and his father before him...

Page 43: Puppet for SysAdmins

Reinvent yourselfevery 2 years

Page 44: Puppet for SysAdmins

The Holy Trinity

IT Ops Management Challenges

Responding to Business Needs

Lack of Visibility

Configuration Drift

Productivity and Efficiency

Page 45: Puppet for SysAdmins

What it's like in the trenches

Service DeskApplication

SupportSystems

AdministratorApplication Developer

Application Developer

Database Administrator

Log call. The console says everything is

green.

Java monitoring tools don’t

show anything either. Call the

developer.

Stop working on new code to troubleshoot.

Need production

logs!

Stop what they’re doing to

identify and gather

production logs for developer.

Manual investigation

establishes not application problem.

DBA analyzes audit logs which

points to bad query.

Escalate. Escalate. Escalate. Respond. Escalate.

Now

what?

Page 46: Puppet for SysAdmins

Monitoring detects the service outage - Nagios

Page 47: Puppet for SysAdmins

Root Cause Analysis- Splunk

• IT Operations review monitoring info, and feed relevant details into Splunkfor event correlation over all enterprise devices

A config file has been manually updated….badly, causing the outage

Page 48: Puppet for SysAdmins

Fix It Once!

• Write a manifest to manage the files and fix the issue

• Maybe use Puppet to write the Nagios cfg� “Exported resources” / templates

• Monitoring = green lights

Page 49: Puppet for SysAdmins

“We're not proggies...we're sys admins!!!”

I know how you feel!

Training did help, eventually ;)

Productive with Puppet in a day or two.

Page 50: Puppet for SysAdmins

Keep Calm and Carry On...again

� Can be completely shell driven – tick

� Server side install from CLI – tick

� Client side install from CLI, with answers file, and SSH bulk install possible - tick

� Can even be run in standalone via cron....can be kept simple, and add value immediately

� Even reads like native language! Dare I say it, 'English'

Page 51: Puppet for SysAdmins

Building a module, the easy way

A simple manifest

`puppet resource service ssh` - outputs valid syntax

A module

`puppet module generate x-blah` - Rename module dir and make sure this is reflected in the class name in manifests/init.pp and tests/init.pp

A class

already in the `tests` directory. Puppet apply -v ./init.pp --noop

Page 52: Puppet for SysAdmins

Any other useful stuff?

What about DR? (Dont forget your certs!)

Automated doco?

/etc/puppet/modules/ssh/manifests# puppet doc ./init.pp

Unit testing -> rspec-puppet

- Mere mortal translation required!

Dependency diagrams

- dot -Tpng /var/opt/lib/pe-puppet/state/graphs/resources.dot -o /tmp/configuration.png

Still sounds risky? --noop

Even the CAB will like you!

Page 53: Puppet for SysAdmins

Puppet Enterprise, why do people choose it?

Many of the tools are pre-compiled

Low stress, upgradable solution

Ceiling install...peace of mind

Dashboard

Mcollective

Cloud Provisioner - AWS & VMWare

Supportable :)

So what your next step?

Page 54: Puppet for SysAdmins

Start small, and KISS!

� “A journey of a 1000 miles...” A.N. Other Smart Person

� Just start!

� Download the training VM

� Do the tutorials

� Use the Forge for inspiration!

� Use Google Groups – [email protected] start

� ...then puppet-dev@ when confidence starts to grow

� Use the supporting toolsets

� Use –noop! Derisk n smile

� Padding on the right shoulder might also be useful...

Page 55: Puppet for SysAdmins

A Quick Recap

Availability

Scalability

Supportability (style, newbies and secure commercial)

Predictability

Agility (all systems, now!)

Cloudability

KeepTheCostsDownAbility...

Smiling end uses (board happy too!)

Legacy migration?

Ops Manager Goals...revisited

Page 56: Puppet for SysAdmins

A Quick Recap

Predictable / stable infrastructure

Reusable wins...version controlled, reusable modules

Fix stuff once...what a concept :)

Reduce support workload, so can finally get to that more interesting project stuff!

Monitoring...that someone else maintains ….well, sorta

Documentation...ditto

Smiling end users, resulting in...

Weekends / sleep

Sysadm Goals...revisted

Page 57: Puppet for SysAdmins

“We're not proggies...we're sys admins!”

Hmmmm…

The good news is that there are plenty options!

Retooling, or....

Page 58: Puppet for SysAdmins

ReferencesLearn Puppet in small chunks...

http://info.puppetlabs.com/download-pdfs.html - leading to http://puppetlabs.com/misc/pdf-doc/

http://forge.puppetlabs.com/

http://theforeman.org

http://docs.puppetlabs.com/guides/tools.html

puppet-rspec - easy intro http://puppetlabs.com/blog/the-next-generation-of-puppet-module-testing/

Puppet for sysadmins...

Page 59: Puppet for SysAdmins

Get to the pub by 5

Who spotted

the cuttlefish?

ps. We are hiring!

Contact: [email protected]