getting started with puppet and vagrant (1)

Post on 02-Jul-2015

441 Views

Category:

Documents

2 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Getting Started with Puppet and Vagrant

Jon Topper The Scale Factory

2 Cool Technologies That Will Actually Change Your Life

Chronology

2000 2005 2010 20151995

Sysadmin Development Lifecycle

Set up test environment

Make change

Did change work?

Commit

Yes

No

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

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

What is Vagrant?

‣ Command line tool

‣ Supports Linux, Mac, Windows

‣ Supports multiple hypervisors

‣ Folder sharing

‣ As portable as your laptop

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.

What is Vagrant?

Operating System

Webserver

Text editor Browser

DatabaseMessenger

Music

Twitter

Photoshop

Filesystem

What is Vagrant?

Operating System

Webserver

Text editor

Browser Database

Messenger

Music

Twitter

Photoshop

Guest O/S

Filesystem

Puppet

‣ Configuration Management tool

‣ “Infrastructure as Code”

‣ Convergent

Puppet

‣ Describe desired system state

‣ “What”, rather than “How”

‣ Puppet moves system from current, to desired state

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

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

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: } }

}

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, } }

}

(Demo)

Benefits

‣ Short cycle time

‣ No copying files around

‣ Share box & manifests with development teams

‣ Easy to try existing config on new operating systems

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

Try it yourself

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

‣ Follow the instructions in the README

‣ Open a new GitHub issue if you get stuck!

http://www.scalefactory.com/

jon@scalefactory.com

@jtopper

scalefactory

top related