Consistent Development Environment with Vagrant and Chef

63
{ { Dev with Ops in Mind Dev with Ops in Mind } } : : Building Consistent Environment with Vagrant and Chef Gerald Z. Villorente Senior Drupal Developer | DevOps Engineer | Proud Dad

Transcript of Consistent Development Environment with Vagrant and Chef

Page 1: Consistent Development Environment with Vagrant and Chef

{{ Dev with Ops in MindDev with Ops in Mind }} :: Building Consistent Environment with

Vagrant and Chef

Gerald Z. VillorenteSenior Drupal Developer | DevOps Engineer | Proud Dad

Page 2: Consistent Development Environment with Vagrant and Chef

About MeAbout Me

Open-source advocateOpen-source advocate Learned how to power on and operate a PC in 2005Learned how to power on and operate a PC in 2005 Became system administrator in 2007Became system administrator in 2007 Became web developer in 2009Became web developer in 2009 Drupalista since 2011Drupalista since 2011 Drupal Developer at CNN Travel | KiteSystems 2011-2013Drupal Developer at CNN Travel | KiteSystems 2011-2013 DevOps Engineer at BodogNation | Novenix Corp. 2013-2014DevOps Engineer at BodogNation | Novenix Corp. 2013-2014

Page 3: Consistent Development Environment with Vagrant and Chef

About MeAbout Me

Started to learn how to use computer in 2005Started to learn how to use computer in 2005 I became a computer technician in 2007I became a computer technician in 2007 I became a Web Developer in 2009I became a Web Developer in 2009 Drupalista since 2011Drupalista since 2011 Drupal Developer at CNN Travel | KiteSystems 2011-2013Drupal Developer at CNN Travel | KiteSystems 2011-2013 DevOps Engineer at BodogNation 2013-2014DevOps Engineer at BodogNation 2013-2014 Drupal Engineer and Mutant at X-Team 2014-presentDrupal Engineer and Mutant at X-Team 2014-present

About MeAbout Me

Started to learn how to use computer in 2005Started to learn how to use computer in 2005 I became a computer technician in 2007I became a computer technician in 2007 I became a Web Developer in 2009I became a Web Developer in 2009 Drupalista since 2011Drupalista since 2011 Drupal Developer at CNN Travel | KiteSystems 2011-2013Drupal Developer at CNN Travel | KiteSystems 2011-2013 DevOps Engineer at BodogNation 2013-2014DevOps Engineer at BodogNation 2013-2014 Drupal Engineer and Mutant at X-Team 2014-presentDrupal Engineer and Mutant at X-Team 2014-present

Drupal Engineer and Mutant at Drupal Engineer and Mutant at X-TeamX-Team 2014-present 2014-present(A global development team of 100+ carefully chosen specialists. )(A global development team of 100+ carefully chosen specialists. )

Page 4: Consistent Development Environment with Vagrant and Chef

About YouAbout You Dev EngineerDev Engineer Ops EngineerOps Engineer DevOps EngineerDevOps Engineer Web ArchitectWeb Architect Not a Graphic Designer (do you really care?)Not a Graphic Designer (do you really care?)

Page 5: Consistent Development Environment with Vagrant and Chef

Dev Setup (traditional)Dev Setup (traditional)

Agenda:

Page 6: Consistent Development Environment with Vagrant and Chef

Bullet Proof SetupBullet Proof Setup

Agenda:

Page 7: Consistent Development Environment with Vagrant and Chef

VagrantVagrant

Agenda:

Page 8: Consistent Development Environment with Vagrant and Chef

Agenda:

Why Vagrant?Why Vagrant?

Page 9: Consistent Development Environment with Vagrant and Chef

Dev with Ops in MindDev with Ops in Mind

Agenda:

Page 10: Consistent Development Environment with Vagrant and Chef

Agenda:

Page 11: Consistent Development Environment with Vagrant and Chef

Agenda:

Why Chef?Why Chef?

Page 12: Consistent Development Environment with Vagrant and Chef
Page 13: Consistent Development Environment with Vagrant and Chef

Dev SetupDev SetupDev SetupDev Setup

Page 14: Consistent Development Environment with Vagrant and Chef

Inconsistent OS between Prod, Dev, Staging, and Local

Page 15: Consistent Development Environment with Vagrant and Chef

Inconsistent Web Server between Prod, Dev, Staging, and Local

IIS ApacheNginX

Lighttpd

Page 16: Consistent Development Environment with Vagrant and Chef

Inconsistent version of libraries, server, and database.

PHP 5.3PHP 5.4

PHP 5.5Apache 2.2

Apache 2.4Drush 4.x

Drush 5.xVarnish 3.x

Varnish 4.xMySQL 5.1

MySQL 5.5

Page 17: Consistent Development Environment with Vagrant and Chef

Inconsistent settings/configurations.

memory_limit = 256Mmax_allowed_packet = 16M

set beresp.http.cache-control = "max-age = 300";upload_max_filesize = 2M

key_buffer = 16Mmax_file_uploads = 20

query_cache_limit = 1M

Page 18: Consistent Development Environment with Vagrant and Chef

Different libraries and extensions (Ex. GD vs. Imagemagick)Different libraries and extensions (Ex. GD vs. Imagemagick)Different libraries and extensions (Ex. GD vs. Imagemagick)Different libraries and extensions (Ex. GD vs. Imagemagick)

Page 19: Consistent Development Environment with Vagrant and Chef
Page 20: Consistent Development Environment with Vagrant and Chef

Unfortunately, most of Unfortunately, most of the time ...the time ...

Unfortunately, most of Unfortunately, most of the time ...the time ...

Page 21: Consistent Development Environment with Vagrant and Chef
Page 22: Consistent Development Environment with Vagrant and Chef
Page 23: Consistent Development Environment with Vagrant and Chef
Page 24: Consistent Development Environment with Vagrant and Chef

Bullet Proof SetupBullet Proof SetupBullet Proof SetupBullet Proof Setup

Page 25: Consistent Development Environment with Vagrant and Chef

Prod = Stage = Dev = LocalProd = Stage = Dev = LocalProd = Stage = Dev = LocalProd = Stage = Dev = Local

Page 26: Consistent Development Environment with Vagrant and Chef

Virtualized EnvironmentsVirtualized EnvironmentsVirtualized EnvironmentsVirtualized Environments

Page 27: Consistent Development Environment with Vagrant and Chef

Consistent operating systems and libraries and extentions.Consistent operating systems and libraries and extentions. New comers can get going with the development right away. No New comers can get going with the development right away. No

more painful setups.more painful setups. Redistributable in case of hardware failure.Redistributable in case of hardware failure.

Consistent operating systems and libraries and extentions.Consistent operating systems and libraries and extentions. New comers can get going with the development right away. No New comers can get going with the development right away. No

more painful setups.more painful setups. Redistributable in case of hardware failure.Redistributable in case of hardware failure.

Reasons why we should:

Page 28: Consistent Development Environment with Vagrant and Chef

Can never get the networking between host and guest OS.Can never get the networking between host and guest OS. Scared of the command line.Scared of the command line. Massive overhead keeping the VM up to date.Massive overhead keeping the VM up to date.

Can never get the networking between host and guest OS.Can never get the networking between host and guest OS. Scared of the command line.Scared of the command line. Massive overhead keeping the VM up to date.Massive overhead keeping the VM up to date.

Reasons why we don't:

Page 29: Consistent Development Environment with Vagrant and Chef

VagrantVagrantVagrantVagrant

Page 30: Consistent Development Environment with Vagrant and Chef

A tool for building and A tool for building and distributing virtualized distributing virtualized

environments.environments.

A tool for building and A tool for building and distributing virtualized distributing virtualized

environments.environments.

Page 31: Consistent Development Environment with Vagrant and Chef

Why Vagrant?Why Vagrant?Why Vagrant?Why Vagrant?

Page 32: Consistent Development Environment with Vagrant and Chef

IsolationIsolationIsolationIsolation

Page 33: Consistent Development Environment with Vagrant and Chef

Mirror ProductionMirror ProductionMirror ProductionMirror Production

Page 34: Consistent Development Environment with Vagrant and Chef

Test Ops scripts Test Ops scripts with a free serverwith a free serverTest Ops scripts Test Ops scripts

with a free serverwith a free server

Page 35: Consistent Development Environment with Vagrant and Chef

Designers and QA Designers and QA can setup their environment can setup their environment

easilyeasily

Designers and QA Designers and QA can setup their environment can setup their environment

easilyeasily

Page 36: Consistent Development Environment with Vagrant and Chef

Faster OnboardingFaster OnboardingFaster OnboardingFaster Onboarding

Page 37: Consistent Development Environment with Vagrant and Chef

DemoDemoDemoDemo

Page 38: Consistent Development Environment with Vagrant and Chef

Getting StartedGetting Started Install Virtualbox | VMwareInstall Virtualbox | VMware Install VagrantInstall Vagrant Import your base OS (Import your base OS ($ vagrant box add [BASE_NAME] [PATH.box]$ vagrant box add [BASE_NAME] [PATH.box])) Generate Vagrantfile config (Generate Vagrantfile config ($ vagrant init [BASE_NAME]$ vagrant init [BASE_NAME])) Boot your guest machine (Boot your guest machine ($ vagrant up$ vagrant up))

Getting StartedGetting Started Install Virtualbox | VMwareInstall Virtualbox | VMware Install VagrantInstall Vagrant Import your base OS (Import your base OS ($ vagrant box add [BASE_NAME] [PATH.box]$ vagrant box add [BASE_NAME] [PATH.box])) Generate Vagrantfile config (Generate Vagrantfile config ($ vagrant init [BASE_NAME]$ vagrant init [BASE_NAME])) Boot your guest machine (Boot your guest machine ($ vagrant up$ vagrant up))

Page 39: Consistent Development Environment with Vagrant and Chef

DistributionDistribution $ vagrant package --base VM_ID --output BOX_NAME.box

DistributionDistribution $ vagrant package --base VM_ID --output BOX_NAME.box

Page 40: Consistent Development Environment with Vagrant and Chef

Dev with Dev with Ops in MindOps in MindDev with Dev with

Ops in MindOps in Mind

Page 41: Consistent Development Environment with Vagrant and Chef

The Goal: Develop Cookbooks The Goal: Develop Cookbooks and Modules to run in a and Modules to run in a

VM and ProductionVM and Production

The Goal: Develop Cookbooks The Goal: Develop Cookbooks and Modules to run in a and Modules to run in a

VM and ProductionVM and Production

Page 42: Consistent Development Environment with Vagrant and Chef

Little Extra EffortLittle Extra EffortBig GainBig Gain

Good PracticesGood Practices

Little Extra EffortLittle Extra EffortBig GainBig Gain

Good PracticesGood Practices

Vagrant and DevOps:

Page 43: Consistent Development Environment with Vagrant and Chef

ChefChefA tool for automating the provisioning and management of serversA tool for automating the provisioning and management of servers

ChefChefA tool for automating the provisioning and management of serversA tool for automating the provisioning and management of servers

Page 44: Consistent Development Environment with Vagrant and Chef

A Good ExampleA Good ExampleA Good ExampleA Good Example

Page 45: Consistent Development Environment with Vagrant and Chef

Why Chef?Why Chef?Why Chef?Why Chef?

Page 46: Consistent Development Environment with Vagrant and Chef

Less documentationLess documentationLess documentationLess documentation

Page 47: Consistent Development Environment with Vagrant and Chef

Bash doesn't scale. Seriously.Bash doesn't scale. Seriously.Bash is a wonderful thing, but like all UNIX tools, it is fundamentally Bash is a wonderful thing, but like all UNIX tools, it is fundamentally limited by design. Bash doesn't have a code reuse mechanism more limited by design. Bash doesn't have a code reuse mechanism more

powerful than functions.powerful than functions.

Bash doesn't scale. Seriously.Bash doesn't scale. Seriously.Bash is a wonderful thing, but like all UNIX tools, it is fundamentally Bash is a wonderful thing, but like all UNIX tools, it is fundamentally limited by design. Bash doesn't have a code reuse mechanism more limited by design. Bash doesn't have a code reuse mechanism more

powerful than functions.powerful than functions.

Page 48: Consistent Development Environment with Vagrant and Chef

Maybe you can do this using “sed”. But hey are you sick? Maybe you can do this using “sed”. But hey are you sick? Maybe you can do this using “sed”. But hey are you sick? Maybe you can do this using “sed”. But hey are you sick?

Page 49: Consistent Development Environment with Vagrant and Chef

Technical Awesomeness.Technical Awesomeness.Technical Awesomeness.Technical Awesomeness.

Page 50: Consistent Development Environment with Vagrant and Chef

NOSQL FTWNOSQL FTWOne of the virtues that many *nix tools share is that they store their One of the virtues that many *nix tools share is that they store their

configurations in text files rather than binary formats or in a configurations in text files rather than binary formats or in a database. database.

Chef stores your system configurations in text Chef stores your system configurations in text and in a database. It accomplishes this by using the document-and in a database. It accomplishes this by using the document-

oriented database, CouchDB.oriented database, CouchDB.

NOSQL FTWNOSQL FTWOne of the virtues that many *nix tools share is that they store their One of the virtues that many *nix tools share is that they store their

configurations in text files rather than binary formats or in a configurations in text files rather than binary formats or in a database. database.

Chef stores your system configurations in text Chef stores your system configurations in text and in a database. It accomplishes this by using the document-and in a database. It accomplishes this by using the document-

oriented database, CouchDB.oriented database, CouchDB.

Page 51: Consistent Development Environment with Vagrant and Chef

Knowing is Half the BattleKnowing is Half the BattleCChef uses Ohai to collect data about your system. Your recipes can hef uses Ohai to collect data about your system. Your recipes can

access these attributes and make decisions based on them.access these attributes and make decisions based on them.

Ex: node['platform_version'] vs. cat | grep | awkEx: node['platform_version'] vs. cat | grep | awk

Knowing is Half the BattleKnowing is Half the BattleCChef uses Ohai to collect data about your system. Your recipes can hef uses Ohai to collect data about your system. Your recipes can

access these attributes and make decisions based on them.access these attributes and make decisions based on them.

Ex: node['platform_version'] vs. cat | grep | awkEx: node['platform_version'] vs. cat | grep | awk

Page 52: Consistent Development Environment with Vagrant and Chef

SearchSearchSearch is a feature in Chef Server that allows you to query the Search is a feature in Chef Server that allows you to query the

configuration information of all other servers and of globally-defined configuration information of all other servers and of globally-defined databags (global variable). This allows you to do things like configure databags (global variable). This allows you to do things like configure clusters where a member of cluster needs to know not only about its clusters where a member of cluster needs to know not only about its

own configuration but about the configurations of the other own configuration but about the configurations of the other members of the cluster.members of the cluster.

SearchSearchSearch is a feature in Chef Server that allows you to query the Search is a feature in Chef Server that allows you to query the

configuration information of all other servers and of globally-defined configuration information of all other servers and of globally-defined databags (global variable). This allows you to do things like configure databags (global variable). This allows you to do things like configure clusters where a member of cluster needs to know not only about its clusters where a member of cluster needs to know not only about its

own configuration but about the configurations of the other own configuration but about the configurations of the other members of the cluster.members of the cluster.

Page 53: Consistent Development Environment with Vagrant and Chef

KnifeKnifeKnife is one of the truly great command line tools. It is your primary Knife is one of the truly great command line tools. It is your primary mechanism for interacting with the chef-server. Knife shares many mechanism for interacting with the chef-server. Knife shares many

usage patterns with git. If you love git, you'll love knife.usage patterns with git. If you love git, you'll love knife.

KnifeKnifeKnife is one of the truly great command line tools. It is your primary Knife is one of the truly great command line tools. It is your primary mechanism for interacting with the chef-server. Knife shares many mechanism for interacting with the chef-server. Knife shares many

usage patterns with git. If you love git, you'll love knife.usage patterns with git. If you love git, you'll love knife.

Page 54: Consistent Development Environment with Vagrant and Chef

ShefShefShef works the way you work, in an iterative manner. Most of us Shef works the way you work, in an iterative manner. Most of us system administrators are self-taught and we learn best by doing. system administrators are self-taught and we learn best by doing. Fire up shef and you can on the fly play with attributes and create Fire up shef and you can on the fly play with attributes and create recipes. Further, you can connect to your server and download the recipes. Further, you can connect to your server and download the

cookbooks.cookbooks.

ShefShefShef works the way you work, in an iterative manner. Most of us Shef works the way you work, in an iterative manner. Most of us system administrators are self-taught and we learn best by doing. system administrators are self-taught and we learn best by doing. Fire up shef and you can on the fly play with attributes and create Fire up shef and you can on the fly play with attributes and create recipes. Further, you can connect to your server and download the recipes. Further, you can connect to your server and download the

cookbooks.cookbooks.

Page 55: Consistent Development Environment with Vagrant and Chef

You can stop You can stop reinventing the wheel.reinventing the wheel.

Until Chef, we sysadmins did not have a truly modular way to Until Chef, we sysadmins did not have a truly modular way to abstract and share our system configurations.abstract and share our system configurations.

You can stop You can stop reinventing the wheel.reinventing the wheel.

Until Chef, we sysadmins did not have a truly modular way to Until Chef, we sysadmins did not have a truly modular way to abstract and share our system configurations.abstract and share our system configurations.

Page 56: Consistent Development Environment with Vagrant and Chef

DemoDemo

Page 57: Consistent Development Environment with Vagrant and Chef

Zero Ruby knowledge?Zero Ruby knowledge?Zero Ruby knowledge?Zero Ruby knowledge?

Page 58: Consistent Development Environment with Vagrant and Chef

rove.iorove.io

Page 59: Consistent Development Environment with Vagrant and Chef

PuPHPetPuPHPet

Page 60: Consistent Development Environment with Vagrant and Chef

Questions?Questions?Questions?Questions?

Page 61: Consistent Development Environment with Vagrant and Chef

1. http://www.scoop.it/1. http://www.scoop.it/2. http://devopsanywhere.blogspot.com/2. http://devopsanywhere.blogspot.com/3. 3. http://www.vagrantup.com/http://www.vagrantup.com/4. 4. https://puphpet.com/https://puphpet.com/5. 5. http://rove.io/http://rove.io/6. 6. http://www.getchef.com/http://www.getchef.com/7. 7. http://puppetlabs.com/http://puppetlabs.com/8. 8. http://www.vagrantbox.es/http://www.vagrantbox.es/9. http://virtualboxes.org/9. http://virtualboxes.org/

References:

Page 62: Consistent Development Environment with Vagrant and Chef

1. Mitchell Hashimoto 1. Mitchell Hashimoto Founder of HashiCorp, Creator of Vagrant and PackerFounder of HashiCorp, Creator of Vagrant and Packer2. Opscode 2. Opscode Creator of ChefCreator of Chef3. Puppet Labs 3. Puppet Labs Creator of PuppetCreator of Puppet

Credits:

Page 63: Consistent Development Environment with Vagrant and Chef

Thank You!!Salamat!Salamat!