Getting started with puppet and vagrant (1)

21
Getting Started with Puppet and Vagrant Jon Topper The Scale Factory

Transcript of Getting started with puppet and vagrant (1)

Page 1: Getting started with puppet and vagrant (1)

Getting Started with Puppet and Vagrant

Jon Topper The Scale Factory

Page 2: Getting started with puppet and vagrant (1)

2 Cool Technologies That Will Actually Change Your Life

Page 3: Getting started with puppet and vagrant (1)

Chronology

2000 2005 2010 20151995

Page 4: Getting started with puppet and vagrant (1)

Sysadmin Development Lifecycle

Set up test environment

Make change

Did change work?

Commit

Yes

No

Page 5: Getting started with puppet and vagrant (1)

Hardware Approach

Set up test environment

Make change

Did change work?

Commit

Yes

No

‣ Walk to server room

‣ Plug in keyboard/monitor

‣ Reboot Server (~2m)

‣ Wait for Kickstart install (~30m)

‣ Upload automation bash scripts

‣ Run them (~15m)

‣ Assess success

Page 6: Getting started with puppet and vagrant (1)

Virtualisation

Set up test environment

Make change

Did change work?

Commit

Yes

No

‣ Use Kickstart to create base image (~30m)

‣ Roll back to VM snapshot

‣ Upload automation bash scripts

‣ Run them (~15m)

‣ Assess success

Page 7: Getting started with puppet and vagrant (1)

What is Vagrant?

‣ Command line tool

‣ Supports Linux, Mac, Windows

‣ Supports multiple hypervisors

‣ Folder sharing

‣ As portable as your laptop

Page 8: Getting started with puppet and vagrant (1)

What is Vagrant?

‣ Import pre-defined “base boxes” from remote servers

‣ Describe box configuration in Vagrantfile

‣ Share both with other people

‣ “vagrant up” starts a clean, new environment

‣ “vagrant destroy” throws it away.

Page 9: Getting started with puppet and vagrant (1)

What is Vagrant?

Operating System

Webserver

Text editor Browser

DatabaseMessenger

Music

Twitter

Photoshop

Filesystem

Page 10: Getting started with puppet and vagrant (1)

What is Vagrant?

Operating System

Webserver

Text editor

Browser Database

Messenger

Music

Twitter

Photoshop

Guest O/S

Filesystem

Page 11: Getting started with puppet and vagrant (1)

Puppet

‣ Configuration Management tool

‣ “Infrastructure as Code”

‣ Convergent

Page 12: Getting started with puppet and vagrant (1)

Puppet

‣ Describe desired system state

‣ “What”, rather than “How”

‣ Puppet moves system from current, to desired state

Page 13: Getting started with puppet and vagrant (1)

Demo Project Structure.!"" README.md!"" Vagrantfile!"" application#   !"" index.php#   $"" ping.php$"" puppet !"" manifests #   $"" site.pp $"" modules !"" demo_apache #   !"" files #   #   $"" httpd.conf #   $"" manifests #   $"" init.pp !"" demo_defaults #   $"" manifests #   $"" init.pp !"" demo_php #   $"" manifests #   $"" init.pp !"" demo_role_database

Page 14: Getting started with puppet and vagrant (1)

VagrantfileVagrant.configure("2") do |config|

# Set up some box defaults. We're going to use the Puppet Labs # CentOS 6.5 x86_64 base box, and give it 1GB RAM

config.vm.box = 'puppetlabs/centos-6.5-64-puppet'

# …

# Set up some Puppet "facts". These will be available to the # puppet manifests when they run.

puppet_facts = { "vagrant" => “1”, "roles" => [ 'webserver', 'database' ] }

# Provision the Vagrant box using Puppet.

config.vm.provision "puppet" do |puppet| puppet.manifests_path = "puppet/manifests" puppet.manifest_file = "site.pp" puppet.module_path = "puppet/modules" puppet.facter = puppet_facts end

end

Page 15: Getting started with puppet and vagrant (1)

Nodeless Configuration

# On every node...

node default {

# ...apply some default settings

class { demo_defaults: }

# Then apply classes for each role we've found via facts:

if( 'webserver' in $roles ) { notice("Found 'webserver' role via Facts") class { demo_role_webserver: } }

if( 'database' in $roles ) { notice("Found 'database' role via Facts") class { demo_role_database: } }

}

Page 16: Getting started with puppet and vagrant (1)

Nodeless Configuration

class demo_defaults {

# ...

# If this is a vagrant box, let's just stop iptables because we don't need # any firewalling.

if( $vagrant ) { service { "iptables": ensure => stopped, enable => false, } }

}

Page 17: Getting started with puppet and vagrant (1)

(Demo)

Page 18: Getting started with puppet and vagrant (1)

Benefits

‣ Short cycle time

‣ No copying files around

‣ Share box & manifests with development teams

‣ Easy to try existing config on new operating systems

Page 19: Getting started with puppet and vagrant (1)

Advanced Usage

‣ Multiple box environments with private networking

‣ “vagrant share” features of Vagrant Cloud

‣ Build production images with the same tools

‣ Build fully automated test suites

Page 20: Getting started with puppet and vagrant (1)

Try it yourself

‣ https://github.com/jtopper/vagrant-demo

‣ Follow the instructions in the README

‣ Open a new GitHub issue if you get stuck!

Page 21: Getting started with puppet and vagrant (1)

http://www.scalefactory.com/

[email protected]

@jtopper

scalefactory