49
2014 DevOps Day – Philippines 2014 DevOps Day – Philippines February 22, 2014 February 22, 2014 Microsoft Philippines Microsoft Philippines 8th Floor, 6750 Ayala Ave., Makati City

Consistent Development Environment using Vagrant and Chef

Embed Size (px)

DESCRIPTION

This presentation is about how to setup a consistent environment using Vagrant and Chef.

Citation preview

Page 1: Consistent Development Environment using Vagrant and Chef

2014 DevOps Day – Philippines2014 DevOps Day – PhilippinesFebruary 22, 2014February 22, 2014

Microsoft PhilippinesMicrosoft Philippines8th Floor, 6750 Ayala Ave., Makati City

Page 2: Consistent Development Environment using Vagrant and Chef

{ { DevOps WayDevOps Way } : Consistent } : Consistent Development Environment using Development Environment using

Vagrant and ChefVagrant and Chef

Gerald Z. VillorenteDevOps Engineer | Drupal Developer | Open-Source EnthusiastDevOps Engineer | Drupal Developer | Open-Source Enthusiast

Gerald Z. VillorenteDevOps Engineer | Drupal Developer | Open-Source EnthusiastDevOps Engineer | Drupal Developer | Open-Source Enthusiast

Page 3: Consistent Development Environment using 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 at X-Team 2014-presentDrupal Engineer 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 at X-Team 2014-presentDrupal Engineer at X-Team 2014-present

Page 4: Consistent Development Environment using Vagrant and Chef

The Traditional SetupThe Traditional Setup What is VagrantWhat is Vagrant Why to use VagrantWhy to use Vagrant DevOps with Vagrant in MindDevOps with Vagrant in Mind What is ChefWhat is Chef Why to use ChefWhy to use Chef

The Traditional SetupThe Traditional Setup What is VagrantWhat is Vagrant Why to use VagrantWhy to use Vagrant DevOps with Vagrant in MindDevOps with Vagrant in Mind What is ChefWhat is Chef Why to use ChefWhy to use Chef

Agenda:Agenda:

Page 5: Consistent Development Environment using Vagrant and Chef

Your Dev and Prod Your Dev and Prod environment environment

are not the same!are not the same! Different Operating SystemsDifferent Operating Systems Different version of PHP|Python|Ruby|Node.jsDifferent version of PHP|Python|Ruby|Node.js Different configuration filesDifferent configuration files Different libraries and extensionsDifferent libraries and extensions

Your Dev and Prod Your Dev and Prod environment environment

are not the same!are not the same! Different Operating SystemsDifferent Operating Systems Different version of PHP|Python|Ruby|Node.jsDifferent version of PHP|Python|Ruby|Node.js Different configuration filesDifferent configuration files Different libraries and extensionsDifferent libraries and extensions

Page 6: Consistent Development Environment using Vagrant and Chef

Well, it worked on my Well, it worked on my machine!machine!

Well, it worked on my Well, it worked on my machine!machine!

Page 7: Consistent Development Environment using Vagrant and Chef

Against DevOps principle!Against DevOps principle!Against DevOps principle!Against DevOps principle!

Page 8: Consistent Development Environment using Vagrant and Chef

Dev and Ops WarDev and Ops WarDev and Ops WarDev and Ops War

Page 9: Consistent Development Environment using Vagrant and Chef

The Right Way!The Right Way!The Right Way!The Right Way!

Page 10: Consistent Development Environment using Vagrant and Chef

Virtualized EnvironmentsVirtualized EnvironmentsVirtualized EnvironmentsVirtualized Environments

Page 11: Consistent Development Environment using Vagrant and Chef

Consistent Operating Systems and PHP|Python|Ruby|Node.js Consistent Operating Systems and PHP|Python|Ruby|Node.js versions between production and development machine.versions between production and development machine.

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 PHP|Python|Ruby|Node.js Consistent Operating Systems and PHP|Python|Ruby|Node.js versions between production and development machine.versions between production and development machine.

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:Reasons why we should:Reasons why we should:Reasons why we should:

Page 12: Consistent Development Environment using 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:Reasons why we don't:Reasons why we don't:Reasons why we don't:

Page 13: Consistent Development Environment using Vagrant and Chef

What What is Vagrant?is Vagrant?

What What is Vagrant?is Vagrant?

Page 14: Consistent Development Environment using 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 15: Consistent Development Environment using Vagrant and Chef

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

Page 16: Consistent Development Environment using Vagrant and Chef

IsolationIsolationIsolationIsolation

Page 17: Consistent Development Environment using Vagrant and Chef

Mirror ProductionMirror ProductionMirror ProductionMirror Production

Page 18: Consistent Development Environment using 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 19: Consistent Development Environment using Vagrant and Chef

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

environment easilyenvironment easily

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

environment easilyenvironment easily

Page 20: Consistent Development Environment using Vagrant and Chef

Faster OnboardingFaster OnboardingFaster OnboardingFaster Onboarding

Page 21: Consistent Development Environment using 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 22: Consistent Development Environment using Vagrant and Chef

DemoDemoDemoDemo

Page 23: Consistent Development Environment using Vagrant and Chef

That's the OS only. That's the OS only. How about the How about the

packages I needed?packages I needed?Should I install them manually?Should I install them manually?

That's the OS only. That's the OS only. How about the How about the

packages I needed?packages I needed?Should I install them manually?Should I install them manually?

Page 24: Consistent Development Environment using Vagrant and Chef

Well, you have 2 options.Well, you have 2 options. Package an existing running environment. Package an existing running environment.

$ vagrant package --base VM_ID --output BOX_NAME.box Use Chef or Puppet to provision that packages and needed config.Use Chef or Puppet to provision that packages and needed config.

Well, you have 2 options.Well, you have 2 options. Package an existing running environment. Package an existing running environment.

$ vagrant package --base VM_ID --output BOX_NAME.box Use Chef or Puppet to provision that packages and needed config.Use Chef or Puppet to provision that packages and needed config.

Page 25: Consistent Development Environment using Vagrant and Chef

DevOps with DevOps with Vagrant in MindVagrant in Mind

DevOps with DevOps with Vagrant in MindVagrant in Mind

Page 26: Consistent Development Environment using Vagrant and Chef

The Goal:The Goal: Develop Develop Cookbooks and Modules Cookbooks and Modules

to run in a to run in a VM and ProductionVM and Production

The Goal:The Goal: Develop Develop Cookbooks and Modules Cookbooks and Modules

to run in a to run in a VM and ProductionVM and Production

Page 27: Consistent Development Environment using 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:Vagrant and DevOps:

Page 28: Consistent Development Environment using 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 29: Consistent Development Environment using Vagrant and Chef

A Good ExampleA Good ExampleA Good ExampleA Good Example

Page 30: Consistent Development Environment using Vagrant and Chef

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

Page 31: Consistent Development Environment using Vagrant and Chef

Less documentationLess documentationLess documentationLess documentation

Page 32: Consistent Development Environment using Vagrant and Chef

Bash doesn't scale. Bash doesn't scale. Seriously.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. Bash doesn't scale. Seriously.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 33: Consistent Development Environment using 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 34: Consistent Development Environment using Vagrant and Chef

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

Page 35: Consistent Development Environment using 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 36: Consistent Development Environment using Vagrant and Chef

Knowing is Half the BattleKnowing is Half the BattleChef uses Ohai to collect data about your system. Your recipes can Chef 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. For example, you can determine which version of Red Hat you are For example, you can determine which version of Red Hat you are

using simply by looking up the value of node['platform_version']. You using simply by looking up the value of node['platform_version']. You don't have to cat | grep | awk to find out which release you are on.don't have to cat | grep | awk to find out which release you are on.

Knowing is Half the BattleKnowing is Half the BattleChef uses Ohai to collect data about your system. Your recipes can Chef 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. For example, you can determine which version of Red Hat you are For example, you can determine which version of Red Hat you are

using simply by looking up the value of node['platform_version']. You using simply by looking up the value of node['platform_version']. You don't have to cat | grep | awk to find out which release you are on.don't have to cat | grep | awk to find out which release you are on.

Page 37: Consistent Development Environment using 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 38: Consistent Development Environment using 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 39: Consistent Development Environment using 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 40: Consistent Development Environment using Vagrant and Chef

Chef grows with you.Chef grows with you.Chef uses pure Ruby as its configuration language, not a shackled Chef uses pure Ruby as its configuration language, not a shackled

subset of ruby, nor yet another custom configuration language. You subset of ruby, nor yet another custom configuration language. You only have to learn a small amount of ruby to get started with chef.only have to learn a small amount of ruby to get started with chef.

Chef grows with you.Chef grows with you.Chef uses pure Ruby as its configuration language, not a shackled Chef uses pure Ruby as its configuration language, not a shackled

subset of ruby, nor yet another custom configuration language. You subset of ruby, nor yet another custom configuration language. You only have to learn a small amount of ruby to get started with chef.only have to learn a small amount of ruby to get started with chef.

Page 41: Consistent Development Environment using 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 42: Consistent Development Environment using Vagrant and Chef

DemoDemoDemoDemo

Page 43: Consistent Development Environment using Vagrant and Chef

I don't know Ruby. How I don't know Ruby. How can I create a robust can I create a robust

script|recipe|manifest?script|recipe|manifest?

I don't know Ruby. How I don't know Ruby. How can I create a robust can I create a robust

script|recipe|manifest?script|recipe|manifest?

Page 44: Consistent Development Environment using Vagrant and Chef

rove.iorove.iorove.iorove.io

Page 45: Consistent Development Environment using Vagrant and Chef

PuPHPetPuPHPetPuPHPetPuPHPet

Page 46: Consistent Development Environment using Vagrant and Chef

Questions?Questions?Questions?Questions?

Page 47: Consistent Development Environment using Vagrant and Chef

Thank You!Thank You!Thank You!Thank You!

Page 48: Consistent Development Environment using 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. http://puppetlabs.com/7. http://puppetlabs.com/

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. http://puppetlabs.com/7. http://puppetlabs.com/

References:References:References:References:

Page 49: Consistent Development Environment using 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

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