Environments line-up! Vagrant & Puppet 101

679 views
550 views

Published on

0 Comments
3 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
679
On SlideShare
0
From Embeds
0
Number of Embeds
23
Actions
Shares
0
Downloads
10
Comments
0
Likes
3
Embeds 0
No embeds

No notes for slide

Environments line-up! Vagrant & Puppet 101

  1. 1. ENVIRONMENTS, LINE UP! VAGRANT & PUPPET 101
  2. 2. ME • Jelrik van Hal • Ingewikkeld • @jelrikvh
  3. 3. MY MESSAGE
  4. 4. ETCETERA, ETCETERA
  5. 5. (random code; don‟t read it)
  6. 6. INSTALLATION
  7. 7. $ cd project $ vagrant init wheezy64 http://someurl.to/wheezy64.box (www.vagrantbox.es)
  8. 8. $ 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.
  9. 9. 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
  10. 10. $ 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 box Successfully added box 'wheezy64' with provider 'virtualbox'!
  11. 11. $ 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
  12. 12. $ vagrant ssh $ vagrant halt $ vagrant reload $ vagrant up $ vagrant destroy
  13. 13. $
  14. 14. $
  15. 15. $ mkdir –p puppet/manifests $ touch puppet/manifests/basenode.pp # Vagrantfile config.vm.provision :puppet do |puppet| puppet.manifests_path = "puppet/manifests" puppet.manifest_file = "basenode.pp" end
  16. 16. # puppet/manifests/basenode.pp Exec { path => [ '/bin/', '/sbin/' , '/usr/bin/‟ ], } package { 'php5': ensure => present, } package { 'mysql-server': ensure => present, } package { 'apache2': ensure => present, }
  17. 17. # puppet/manifests/basenode.pp (...) package { 'apache2': ensure => present, }
  18. 18. # 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 }
  19. 19. # 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”] }
  20. 20. THE WAY TO GO? I wouldn‟t say so. There is too much we need to know.
  21. 21. PLUG AND PLAY MODULES https://github.com/example42 http://forge.puppetlabs.com …
  22. 22. # Vagrantfile config.vm.provision :puppet do |puppet| puppet.manifests_path = "puppet/manifests" puppet.modules_path = "puppet/modules" puppet.manifest_file = "basenode.pp" end
  23. 23. $ ls puppet/modules/apache/ Modulefile README.md Rakefile manifests spec templates
  24. 24. # 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', }
  25. 25. $ vagrant up $ vagrant up --provision $ vagrant provision
  26. 26. SO, WHY VAGRANT? • No more “works on my machine” • The right software, and nothing more • Clean development machine • Power of provisioning
  27. 27. WHAT‟S MORE? • Multiple machines • On Windows • Please note: Vagrant 1.2 -> 1.3
  28. 28. @skoop @jelrikvh @mvriel
  29. 29. @jelrikvh http://www.vagrantup.com/ http://www.vagrantbox.es/ https://github.com/example42?tab=repositories http://forge.puppetlabs.com/
  30. 30. THANKS!

×