environments line-up! vagrant & puppet 101

43
VAGRANT & PUPPET 101 ENVIRONMENTS, LINE UP!

Upload: jelrikvh

Post on 06-May-2015

353 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: Environments line-up! Vagrant & Puppet 101

VAGRANT & PUPPET 101

ENVIRONMENTS, LINE UP!

Page 2: Environments line-up! Vagrant & Puppet 101

ME

• Jelrik van Hal

• Ingewikkeld

• @jelrikvh

Page 3: Environments line-up! Vagrant & Puppet 101

MY MESSAGE

Page 4: Environments line-up! Vagrant & Puppet 101
Page 5: Environments line-up! Vagrant & Puppet 101

ETCETERA, ETCETERA

Page 6: Environments line-up! Vagrant & Puppet 101
Page 7: Environments line-up! Vagrant & Puppet 101
Page 8: Environments line-up! Vagrant & Puppet 101
Page 9: Environments line-up! Vagrant & Puppet 101
Page 10: Environments line-up! Vagrant & Puppet 101
Page 11: Environments line-up! Vagrant & Puppet 101

(random code; don’t read it)

Page 12: Environments line-up! Vagrant & Puppet 101

INSTALLATION

Page 13: Environments line-up! Vagrant & Puppet 101

$ cd project$ vagrant init

(www.vagrantbox.es)

http://someurl.to/wheezy64.boxwheezy64

Page 14: Environments line-up! Vagrant & Puppet 101

$ vagrant init wheezy64 http://someurl.to/wheezy64.box

A `Vagrantfile` has been placed in this directory. You are now ready to `vagrant up` your first virtual environment! Please read the comments in the Vagrantfile as well as documentation on `vagrantup.com` for more information on using Vagrant.

Page 15: Environments line-up! Vagrant & Puppet 101

Vagrant.configure("2") do |config| config.vm.box = "wheezy64" config.vm.box_url = "http://someurl.to/wheezy64.box"  config.vm.network :forwarded_port, guest: 80, host: 8080 config.vm.network :private_network, ip: "192.168.42.42"  config.vm.synced_folder ".", "/vagrant"end

Page 16: Environments line-up! Vagrant & Puppet 101

$ vagrant up

Bringing machine 'default' up with 'virtualbox' provider...[default] Box 'wheezy64' was not found. Fetching box from specified URL for the provider 'virtualbox'. Note that if the URL does not have a box for this provider, you should interrupt Vagrant now and add the box yourself. Otherwise Vagrant will attempt to download the full box prior to discovering this error.Downloading or copying the box...Extracting boxSuccessfully added box 'wheezy64' with provider 'virtualbox'!

Page 17: Environments line-up! Vagrant & Puppet 101

$ vagrant up

[default] Importing base box 'wheezy64'...[default] Matching MAC address for NAT networking...[default] Setting the name of the VM...[default] Clearing any previously set forwarded ports...[default] Creating shared folders metadata...[default] Clearing any previously set network interfaces...[default] Preparing network interfaces based on configuration...[default] Forwarding ports...[default] -- 22 => 2222 (adapter 1)[default] -- 80 => 8080 (adapter 1)[default] Booting VM...[default] Waiting for VM to boot. This can take a few minutes.[default] VM booted and ready for use![default] Configuring and enabling network interfaces...[default] Mounting shared folders...[default] -- /vagrant

Page 18: Environments line-up! Vagrant & Puppet 101

$ vagrant ssh

$ vagrant halt

$ vagrant reload

$ vagrant up

$ vagrant destroy

Page 19: Environments line-up! Vagrant & Puppet 101
Page 20: Environments line-up! Vagrant & Puppet 101
Page 21: Environments line-up! Vagrant & Puppet 101
Page 22: Environments line-up! Vagrant & Puppet 101
Page 23: Environments line-up! Vagrant & Puppet 101
Page 24: Environments line-up! Vagrant & Puppet 101

$

Page 25: Environments line-up! Vagrant & Puppet 101
Page 26: Environments line-up! Vagrant & Puppet 101

$

Page 27: Environments line-up! Vagrant & Puppet 101
Page 28: Environments line-up! Vagrant & Puppet 101

$ mkdir –p puppet/manifests

$ touch puppet/manifests/basenode.pp

# Vagrantfileconfig.vm.provision :puppet do |puppet| puppet.manifests_path = "puppet/manifests" puppet.manifest_file = "basenode.pp"end

Page 29: Environments line-up! Vagrant & Puppet 101

# puppet/manifests/basenode.ppExec { path => [ '/bin/', '/sbin/' , '/usr/bin/’ ],} package { 'php5': ensure => present,} package { 'mysql-server': ensure => present,} package { 'apache2': ensure => present,}

Page 30: Environments line-up! Vagrant & Puppet 101

# puppet/manifests/basenode.pp

(...)

package { 'apache2': ensure => present,}

Page 31: Environments line-up! Vagrant & Puppet 101

# puppet/manifests/basenode.pp

(...)

file { "configure_vhost": ensure => present, path => "/path/to/apache/config/folder", owner => ‘root', group => ‘root', mode => '0600', source => 'puppet:///files/vhost_template’, replace => false}

Page 32: Environments line-up! Vagrant & Puppet 101

# puppet/manifests/basenode.pp

(...)

file { "configure_vhost": ensure => present, path => "/path/to/apache/config/folder", owner => ‘root', group => ‘root', mode => '0600', source => 'puppet:///files/vhost_template’, replace => false, require => Package["apache2"], notify => Service[“apache2”]}

Page 33: Environments line-up! Vagrant & Puppet 101

THE WAY TO GO?

I wouldn’t say so.

There is too much we need to know.

Page 34: Environments line-up! Vagrant & Puppet 101

PLUG AND PLAY MODULES

https://github.com/example42

http://forge.puppetlabs.com

Page 35: Environments line-up! Vagrant & Puppet 101

# Vagrantfileconfig.vm.provision :puppet do |puppet| puppet.manifests_path = "puppet/manifests" puppet.modules_path = "puppet/modules" puppet.manifest_file = "basenode.pp"end

Page 36: Environments line-up! Vagrant & Puppet 101

$ ls puppet/modules/apache/

Modulefile README.md Rakefile manifests spec templates

Page 37: Environments line-up! Vagrant & Puppet 101

# puppet/manifests/basenode.pp

(...)

class { "apache": }

apache::vhost { 'default': docroot => '/var/www/document_root', server_name => ‘dev.example.org’, priority => '', template => 'apache/virtualhost/vhost.conf.erb',}

Page 38: Environments line-up! Vagrant & Puppet 101

$ vagrant up

$ vagrant up --provision

$ vagrant provision

Page 39: Environments line-up! Vagrant & Puppet 101

SO, WHY VAGRANT?

• No more “works on my machine”

• The right software, and nothing more

• Clean development machine

• Power of provisioning

Page 40: Environments line-up! Vagrant & Puppet 101

WHAT’S MORE?

• Multiple machines

• On Windows

• Please note: Vagrant 1.2 -> 1.3

Page 41: Environments line-up! Vagrant & Puppet 101

@skoop @jelrikvh @mvriel

Page 42: Environments line-up! Vagrant & Puppet 101

http://www.vagrantup.com/ http://www.vagrantbox.es/https://github.com/example42?tab=repositories

http://forge.puppetlabs.com/

@jelrikvh

Page 43: Environments line-up! Vagrant & Puppet 101

THANKS!