Adam Culp will talk about using Vagrant to create and manage virtualized development environments, making it easier to mirror production servers. Then will cover using Puppet for more advanced provisioning, making the addition of multiple development environments and servers easier and faster.
If you’re developing and are not sure what these technologies are, this talk is for you. As a developer it’s increasingly important to ensure our development, testing, staging, and production environments are as closely matched to each other as possible, alleviating the “can’t reproduce it on my machine” excuses. Whether you use 2, 3, or 4 of these environments is of less importance if they are all built on the same “stack” of applications.
2. 2
Vagrant for Virtualized Development
●
About me
– PHP 5.3 Certified
– Consultant at Zend Technologies
– Organizer SoFloPHP (South Florida)
– Organized SunshinePHP (Miami)
– Long distance (ulramarathon) runner
– Judo Black Belt Instructor
3. 3
Vagrant for Virtualized Development
● Shortfalls of development environments
– Does not mirror “testing” or “production” setup.
– Each developer has a different one.
● Easily out of sync with standards
● Many versions of (php, mysql, apache, etc.)
– Long ramp-up/training for new developers
– It works for me!
4. 4
Vagrant for Virtualized Development
● Vagrant - http://vagrantup.com
– Virtualized development environments made easy
●
Command line tool
●
Lowers setup time
● Fully control entire environments and versions
● Eliminates “works on my machine” excuse
● Uses:
– VirtualBox
– VMWare
– AWS
– Others....
● Can use Puppet or Chef
● FREE and open source
5. 5
Vagrant for Virtualized Development
●
Benefits of Using Vagrant
– Solo Developers
●
Maintain consistency across multiple projects.
●
Can run multiple environments on a single host machine.
(Dev., Test, Staging)
●
Easily tear down and rebuild.
– Teams
●
Identical development environments.
●
Consistent and portable.
– Companies
●
Easier onboarding of new talent.
●
Build once and distribute to teams.
6. 6
Vagrant for Virtualized Development
● Vagrant minimum requirements
– VirtualBox and Hyper-V supported out of the box
– Ruby
– Vagrant
● Installers for MAC, Windows, various Linux
● Talks to VirtualBox and builds virtual machine based on a “base box”.
– Chef or Puppet
● These require separate installation
● Enables setup and configuration of advanced services you may need in your
environment.
7. 7
Vagrant for Virtualized Development
● Vagrant Basic “How To”
– Navigate (via terminal) to your project.
– Find a base box: http://vagrantbox.es
– Execute two simple commands:
● vagrant init
● vagrant up
9. 9
Vagrant for Virtualized Development
● Vagrant Base Box Commands
– Many base boxes available over the Internet, or
you can create your own.
● Creation convention should be followed.
– A base box must be added via local file or HTTP.
10. 10
Vagrant for Virtualized Development
● Vagrant Base Box Commands
– You can list current “installed” base boxes.
11. 11
Vagrant for Virtualized Development
● Vagrant Base Box Commands
– Or you can remove current base boxes.
● Remember to include provider.
12. 12
Vagrant for Virtualized Development
● Vagrant Configuration File (Vagrantfile)
– Simple Ruby code which typically contains a Vagrant
configuration block.
– First thing loaded by Vagrant.
– Basic file created when 'init' is called from within a
directory.
– Add more options for more configuration.
14. 14
Vagrant for Virtualized Development
● Suspend / Halt / Destroy
– To shut down we can:
● “suspend” to save the current state of the
machine. (does not return disk space, about
1GB)
● “halt” which is a graceful shutdown.
●
“destroy” everything. (requires re-provision)
– If we “suspended” to shut down last time you can
use “vagrant resume” or “vagrant up” when
returning, otherwise we use “vagrant up”.
15. 15
Vagrant for Virtualized Development
●
SSH
– Vagrant makes SSH to the virtual machine easy
from within the project directory.
– Project files are available in the VM at '/vagrant' by
default, but can be changed.
– The VM has both read and write access to the
shared folder.
– Gain root (su) access use “sudo”.
16. 16
Vagrant for Virtualized Development
● Port Forwarding
– By default your host machine should be able to
access the virtual machine by IP address. However,
we need to activate port forwarding for services.
– For HTTP:
– Then we simply reload Vagrant.
$ vagrant reload
17. 17
Vagrant for Virtualized Development
● Provisioning
– We can set up some provisioning automation in
Vagrant by including a shell script.
– Link to a shell script in the Vagrantfile.
19. 19
Vagrant for Virtualized Development
●
Packaging Your Own
– Start with a Base Box
●
Customize it as needed, unless relying solely on
provisioning with Chef or Puppet.
●
Run command to package
$ vagrant package –vagrantfile Vagrantfile.pkg
●
Creates 'package.box' in same directory.
●
Distribute via raw file or via HTTP, for others.
●
Other users can now use:
$ vagrant box add my_box /path/to/the/package.box
$ vagrant init my_box
$ vagrant up
20. 20
Vagrant for Virtualized Development
● Packaging Your Own (from scratch)
– Simple enough to do.
– Follow Vagrant standards, especially if you plan to
share it.
● Set sizes of partition and RAM.(40GB/360MB)
● Set Domain and Hostname
●
Create Vagrant user, and password.
● Create some groups
● Ruby, RubyGems, Puppet, Chef, SSH with public keys
● Set sudo permissions
● Create /vagrant directory
21. 21
Vagrant for Virtualized Development
● Provisioning
– Using Chef or Puppet we can create a script to alter
the VM.
●
Install apps
●
Edit config files
●
Many tasks needed to go from Base Box to desired
environment.
– Manifests (or recipe for Chef)
●
Manifests sub-directory within project.
●
Default.pp is the default file loaded.
22. 22
Vagrant for Virtualized Development
● Advanced Capabilities of Vagrant
– Many advanced topics available under
Documentation on the Vagrant site.
●
Modules within Manifests to encapsulate Puppet
files.
●
Create your own Base Boxes
●
Multi-VM Environment
●
Plugins
●
NFS Shared Folders
23. 23
Vagrant for Virtualized Development
● Puppet is:
– Automation software
● Help system admins manage infrastructure.
– Automates provisioning and configuration
– Automate repetitive tasks
– Ensure stability through consistency
– Open source and commercial versions
24. 24
Vagrant for Virtualized Development
● Puppet Supported Operating Systems:
– RHEL
– CentOS
– Ubuntu
– Debian
– Scientific Linux
– Oracle Linux
– SUSE
– Solaris
– Windows
25. 25
Vagrant for Virtualized Development
● Pieces
– Modules for popular
configurations
– Compose application
stack needed
– Rollout to the node
26. 26
Vagrant for Virtualized Development
● Puppet Training
– Materials available on PuppetLabs site for FREE download.
●
Learning Puppet Tutorial
●
Learn Puppet VM to train on (VMWare or VirtualBox)
● Module cheatsheet
● Core types cheatsheet
● Users Guide
● Dashboard Manual
27. 27
Vagrant for Virtualized Development
●
New tool PuPHPet
– Complex Vagrant setups made easy GUI.
●
Puppet manifest creation
●
Host (local, Digital Ocean, Rackspace).
●
Ubuntu version.
●
Set VM options.
● HTTP server. (Apache, Nginx)
●
PHP version. (5.5, 5.4, 5.3)
●
Or HHVM
●
Debugger (Xdebug).
●
Profiler (XHProf).
●
Drush
●
Database. (MySQL, PostgreSQL, MariaDB, MongoDB, Redis)
● Beantalkd or RabitMQ
●
Elastic Search
●
Create!
28. 28
Vagrant for Virtualized Development
● New tool Rove.io
– Complex Vagrant setups made easy GUI.
●
Chef recipe creation
●
Database. (various)
● Language. (Node.js, PHP, Python, Ruby)
● SCM (Git, Mercurial, Subversion)
● HTTP server (Apache, Nginx)
● Generate!
29. 29
Vagrant for Virtualized Development
● Resources
– http://vagrantup.com
– http://puppetlabs.com
– http://opscode.com/chef/
– http://virtualbox.org
– http://puPHPet.com
– http://getcomposer.org
– http://github.com
View details, slides, and rate at https://joind.in/10538
30. ● Thank you
Adam Culp
http://www.geekyboy.com
http://github.com/adamculp
Twitter @adamculp
View details, slides, and rate at https://joind.in/10538