getting your toolbox together

177
Getting Your Toolbox Together Daan van Renterghem June 7th, 2013

Upload: drvr

Post on 20-May-2015

420 views

Category:

Technology


1 download

DESCRIPTION

Slides for my talk "Getting Your Toolbox Together", which I gave a DPC 2013.

TRANSCRIPT

Page 1: Getting Your Toolbox Together

Getting Your Toolbox Together

Daan van Renterghem

June 7th, 2013

Page 2: Getting Your Toolbox Together

Welcome!

Daan van Renterghem

Software Engineer @Ibuildings

Page 3: Getting Your Toolbox Together

Welcome!

Daan van Renterghem

Software Engineer @Ibuildings

https://joind.in/8453

Page 4: Getting Your Toolbox Together

Welcome!

Daan van Renterghem

Software Engineer @Ibuildings

Conference Social!

Page 5: Getting Your Toolbox Together

What is this talk about?

Page 6: Getting Your Toolbox Together

Story Time!

http://thedailygrowl.co.uk/2009/10/14/its-story-time/

Page 7: Getting Your Toolbox Together

Welcome Aboard!

Page 8: Getting Your Toolbox Together

Welcome Aboard!

http://www.quickmeme.com

Page 9: Getting Your Toolbox Together

Welcome Aboard!

All you have to do…

Page 10: Getting Your Toolbox Together

Welcome Aboard!

All you have to do…• Step 1: get the code from VCS

Page 11: Getting Your Toolbox Together

Welcome Aboard!

All you have to do…• Step 1: get the code from VCS• Step 2: download base image

Page 12: Getting Your Toolbox Together

Welcome Aboard!

All you have to do…• Step 1: get the code from VCS• Step 2: download base image• Step 3: configure shared folders

Page 13: Getting Your Toolbox Together

Welcome Aboard!

All you have to do…• Step 1: get the code from VCS• Step 2: download base image• Step 3: configure shared folders• Step 4: start image, say it is copied over, create a new shell user, transfer ownership of

this list of files to yourself, make sure these folders are writeable, mount your shared folder, check if your virtual hosts settings are correct, that your /etc/hosts file is pointing to the correct IP, which you need to get from the VM, oh, and if you’re not using linux, just google for the location of the hosts file, check if the browser doesn’t show the default it works page, resolve a bunch of errors to get the application up and running, ah cool, that’s at least not a fatal error! Ehhhr, yeah, I believe that is caused because of this, oh, and you need to run this list of database patches in that particular sequence, and then resolve some more errors, create you local configuration, and just see if you can get the thing to work, it took me only 5 days, so yeah… Good luck!

Page 14: Getting Your Toolbox Together

In other words:

Page 15: Getting Your Toolbox Together

In other words:

Page 16: Getting Your Toolbox Together

Could it be done differently?

Page 17: Getting Your Toolbox Together

Could it be done differently?

Yes, yes it could!

Page 18: Getting Your Toolbox Together

Could it be done differently?

Yes, yes it could!

And it should!

Page 19: Getting Your Toolbox Together

Welcome Aboard (Tooling Style)

Page 20: Getting Your Toolbox Together

Welcome Aboard (Tooling Style)

• Step 1: get the code from VCS

Page 21: Getting Your Toolbox Together

Welcome Aboard (Tooling Style)

• Step 1: get the code from VCS• Step 2: copy configuration sample

Page 22: Getting Your Toolbox Together

Welcome Aboard (Tooling Style)

• Step 1: get the code from VCS• Step 2: copy configuration sample• Step 3: run “vagrant up”

Page 23: Getting Your Toolbox Together

Welcome Aboard (Tooling Style)

• Step 1: get the code from VCS• Step 2: copy configuration sample• Step 3: run “vagrant up”• Step 4: ???

Page 24: Getting Your Toolbox Together

Your Toolbox

Page 25: Getting Your Toolbox Together

Tools, what do you mean?

Page 26: Getting Your Toolbox Together

Tools, what do you mean?

Having a toolbox means you are using tools to solve problems (rather than checklists and procedures)

Page 27: Getting Your Toolbox Together

Tools, what do you mean?

Having a toolbox means you are using tools to solve problems (rather than checklists and procedures)

Make development, maintenance and deployment as easy and fast as possible, with the least amount of interaction.

Page 28: Getting Your Toolbox Together

Why are Tools important?

Page 29: Getting Your Toolbox Together

Why are Tools important?

In devops you either are contribute to tool or you are tool.

- DevOps Borat

https://twitter.com/DEVOPS_BORAT/status/139898439621296129

Page 30: Getting Your Toolbox Together

Why are Tools important?

In devops you either are contribute to tool or you are tool.

- DevOps Borat

Tools help you accomplish (repetitive) tasks in an easy, consistent manner.

https://twitter.com/DEVOPS_BORAT/status/139898439621296129

Page 31: Getting Your Toolbox Together

Why are Tools important?

In devops you either are contribute to tool or you are tool.

- DevOps Borat

Tools help you accomplish (repetitive) tasks in an easy, consistent manner.

Added bonus: no human error

https://twitter.com/DEVOPS_BORAT/status/139898439621296129

Page 32: Getting Your Toolbox Together

When to use tools?

Page 33: Getting Your Toolbox Together

Chances are

You’re already using tools!

Page 34: Getting Your Toolbox Together

Chances are

You’re already using tools!• VCS

Page 35: Getting Your Toolbox Together

Chances are

You’re already using tools!• VCS• Editor / IDE

Page 36: Getting Your Toolbox Together

Chances are

You’re already using tools!• VCS• Editor / IDE• CI - server

Page 37: Getting Your Toolbox Together

Where can tools be used

Page 38: Getting Your Toolbox Together

Where can tools be used

• Code Management

Page 39: Getting Your Toolbox Together

Where can tools be used

• Code Management• Development Environment

Page 40: Getting Your Toolbox Together

Where can tools be used

• Code Management• Development Environment• Any other environment

Page 41: Getting Your Toolbox Together

Where can tools be used

• Code Management• Development Environment• Any other environment

• Deployment

Page 42: Getting Your Toolbox Together

Where can tools be used

• Code Management• Development Environment• Any other environment

• Deployment• Quality Control

Page 43: Getting Your Toolbox Together

Where can tools be used

• Code Management• Development Environment• Any other environment

• Deployment• Quality Control• Monitoring

Page 44: Getting Your Toolbox Together

Where can tools be used

• Code Management• Development Environment• Any other environment

• Deployment• Quality Control• Monitoring

Page 45: Getting Your Toolbox Together

Development Environment

Page 46: Getting Your Toolbox Together

Development Environment

Page 47: Getting Your Toolbox Together

Development Environment

Different options

Page 48: Getting Your Toolbox Together

Development Environment

Different options• Local Webserver

Page 49: Getting Your Toolbox Together

Development Environment

Different options• Local Webserver• Single Shared Server

Page 50: Getting Your Toolbox Together

Development Environment

Different options• Local Webserver• Single Shared Server• Development Images

Page 51: Getting Your Toolbox Together

Local Webserver

Pro: Con:

Page 52: Getting Your Toolbox Together

Local Webserver

Pro:•Portable

Con:

Page 53: Getting Your Toolbox Together

Local Webserver

Pro:•Portable

Con:•No consistent environment

Page 54: Getting Your Toolbox Together

Local Webserver

Pro:•Portable

Con:•No consistent environment•Multiple projects can cause conflicts

Page 55: Getting Your Toolbox Together

Local Webserver

Pro:•Portable

Con:•No consistent environment•Multiple projects can cause conflicts•Different OS, different build

Page 56: Getting Your Toolbox Together

Single Shared Server

Pro: Con:

Page 57: Getting Your Toolbox Together

Single Shared Server

Pro:•Possible per project

Con:

Page 58: Getting Your Toolbox Together

Single Shared Server

Pro:•Possible per project

Con:•Single state for everyone

Page 59: Getting Your Toolbox Together

Single Shared Server

Pro:•Possible per project

Con:•Single state for everyone•Single state for every project

Page 60: Getting Your Toolbox Together

Single Shared Server

Pro:•Possible per project

Con:•Single state for everyone•Single state for every project•Costs (hardware, management)

Page 61: Getting Your Toolbox Together

Single Shared Server

Pro:•Possible per project

Con:•Single state for everyone•Single state for every project•Costs (hardware, management)•Downtime, network

Page 62: Getting Your Toolbox Together

Development Image

Pro: Con:

Page 63: Getting Your Toolbox Together

Development Image

Pro:•Specific per project

Con:

Page 64: Getting Your Toolbox Together

Development Image

Pro:•Specific per project•Portable

Con:

Page 65: Getting Your Toolbox Together

Development Image

Pro:•Specific per project•Portable•Consistent stack between devs

Con:

Page 66: Getting Your Toolbox Together

Development Image

Pro:•Specific per project•Portable•Consistent stack between devs•Allows for local differences where needed

Con:

Page 67: Getting Your Toolbox Together

Development Image

Pro:•Specific per project•Portable•Consistent stack between devs•Allows for local differences where needed

Con:•Takes time to set up

Page 68: Getting Your Toolbox Together

Development Image

Page 69: Getting Your Toolbox Together

Development Image

Requirements

Page 70: Getting Your Toolbox Together

Development Image

Requirements• Reliable, maintainable

Page 71: Getting Your Toolbox Together

Development Image

Requirements• Reliable, maintainable• OS agnostic

Page 72: Getting Your Toolbox Together

Development Image

Requirements• Reliable, maintainable• OS agnostic• Allow for consistent configuration

Page 73: Getting Your Toolbox Together

Development Image

Requirements• Reliable, maintainable• OS agnostic• Allow for consistent configuration• Reusable, Idempotent

Page 74: Getting Your Toolbox Together

Development Image

Now we know what we want, but how to create one?

Page 75: Getting Your Toolbox Together

Development Image

Now we know what we want, but how to create one?

Use a tool!

Page 76: Getting Your Toolbox Together

Development Image

Now we know what we want, but how to create one?

Use Vagrant!

Page 77: Getting Your Toolbox Together

Vagrant

Page 78: Getting Your Toolbox Together

Vagrant

Page 79: Getting Your Toolbox Together

Vagrant

Create and configure lightweight, reproducible, and portable development environments.

Page 80: Getting Your Toolbox Together

Vagrant

Create and configure lightweight, reproducible, and portable development environments.•Provider agnostic

Page 81: Getting Your Toolbox Together

Vagrant

Create and configure lightweight, reproducible, and portable development environments.•Provider agnostic•Uses “boxes”: base images to quickly clone a virtual machine

Page 82: Getting Your Toolbox Together

Vagrant

Create and configure lightweight, reproducible, and portable development environments.•Provider agnostic•Uses “boxes”: base images to quickly clone a virtual machine•Provisioning: automated installation of software

Page 83: Getting Your Toolbox Together

Vagrant - Resources

Page 84: Getting Your Toolbox Together

Vagrant - Resources

Website:http://www.vagrantup.com

Page 85: Getting Your Toolbox Together

Vagrant - Resources

Website:http://www.vagrantup.com

Installation:http://downloads.vagrantup.com

Page 86: Getting Your Toolbox Together

Vagrant - Resources

Website:http://www.vagrantup.com

Installation:http://downloads.vagrantup.com

Documentation:http://docs.vagrantup.com

Page 87: Getting Your Toolbox Together

Vagrant - Usage

Page 88: Getting Your Toolbox Together

Vagrant - Boxes

Box: Portable files which can be used by others on any platform that runs Vagrant to bring up a working environment.

Page 89: Getting Your Toolbox Together

Vagrant - Boxes

Box: Portable files which can be used by others on any platform that runs Vagrant to bring up a working environment.

$ vagrant box add <name> <url> <provider>

Page 90: Getting Your Toolbox Together

Vagrant - Boxes

Box: Portable files which can be used by others on any platform that runs Vagrant to bring up a working environment.

$ vagrant box add <name> <url> <provider>

http://www.vagrantbox.es

Page 91: Getting Your Toolbox Together

Vagrant - Boxes

Define configuration, in Vagrantfile

Page 92: Getting Your Toolbox Together

Vagrant - Boxes

Define configuration, in Vagrantfile

Vagrant.configure("2") do |config|

config.vm.box = "<name>"

end

Page 93: Getting Your Toolbox Together

Vagrant - Configuration

Configure amount of memory, give it a name

Vagrant.configure("2") do |config|

config.vm.customize [

"modifyvm", :id,

"--name", "foobar",

"--memory", 2048

]

end

Page 94: Getting Your Toolbox Together

Vagrant - Configuration

Shared folder configuration

Vagrant.configure("2") do |config|

config.vm.share_folder(

"htdocs",

"/var/www/my_project/"

"/path/to/local/folder"

)

end

Page 95: Getting Your Toolbox Together

Vagrant - Configuration

Using local configurationrequire "yaml"

conf = YAML.load_file(

"./deploy/dev/conf.yaml"

)

Page 96: Getting Your Toolbox Together

Vagrant - Configuration

Using local configurationrequire "yaml"

conf = YAML.load_file(

"./deploy/dev/conf.yaml"

)

Vagrant.configure("2") do |config|

# conf available here

end

Page 97: Getting Your Toolbox Together

Vagrant - Configuration

Shared folder configuration

Vagrant.configure("2") do |config|

config.vm.share_folder(

"htdocs",

"/var/www/" + conf["project_name"],

conf["shared_folder"]

)

end

Page 98: Getting Your Toolbox Together

Vagrant - Configuration

We can localize this too!

Vagrant.configure("2") do |config|

config.vm.customize [

"modifyvm", :id,

"--name", conf["project_name"],

"--memory", conf["mem_limit"]

]

end

Page 99: Getting Your Toolbox Together

Vagrant - Configuration

Even the IP on which it can be reached.

Vagrant.configure("2") do |config|

config.vm.network :hostonly, conf["ip"]

end

Page 100: Getting Your Toolbox Together

Vagrant - Configuration

Basic configuration

Page 101: Getting Your Toolbox Together

Vagrant - Configuration

Basic configuration•Commit Vagrantfile to VCS

Page 102: Getting Your Toolbox Together

Vagrant - Configuration

Basic configuration•Commit Vagrantfile to VCS•Commit sample dev config to VCS

Page 103: Getting Your Toolbox Together

Vagrant - Configuration

Basic configuration•Commit Vagrantfile to VCS•Commit sample dev config to VCS•Ignore dev config

Page 104: Getting Your Toolbox Together

Vagrant - Commands

Page 105: Getting Your Toolbox Together

Vagrant - Commands

• $ vagrant up

• $ vagrant halt

• $ vagrant suspend

• $ vagrant resume

• $ vagrant destroy

• $ vagrant provision

Page 106: Getting Your Toolbox Together

Vagrant – Recap

Page 107: Getting Your Toolbox Together

Vagrant

Single command to get your VM running

Page 108: Getting Your Toolbox Together

Vagrant

Single command to get your VM running

$ vagrant up

Page 109: Getting Your Toolbox Together

Vagrant

Single command to get your VM running

$ vagrant up

And it’s running!

Page 110: Getting Your Toolbox Together

Vagrant

Single command to get your VM running

$ vagrant up

And it’s running!But that’s not usable as server right now…

Page 111: Getting Your Toolbox Together

Vagrant

We have a machine…

Page 112: Getting Your Toolbox Together

Vagrant

We have a machine…… but its not a server

Page 113: Getting Your Toolbox Together

Vagrant

We have a machine…… but its not a server

Page 114: Getting Your Toolbox Together

Vagrant

We have a machine…… but its not a server… and we do not want everyone to install everything themselves

Page 115: Getting Your Toolbox Together

Vagrant

We have a machine…… but its not a server… and we do not want everyone to install everything themselves

Enter: Provisioning

Page 116: Getting Your Toolbox Together

Vagrant

We have a machine…… but its not a server… and we do not want everyone to install everything themselves

Enter: Provisioning

Page 117: Getting Your Toolbox Together

Vagrant - Provisioning

Configuration Management

Page 118: Getting Your Toolbox Together

Vagrant - Provisioning

Provisioning

Page 119: Getting Your Toolbox Together

Vagrant - Provisioning

Provisioning

+

Page 120: Getting Your Toolbox Together

Vagrant - Provisioning

Provisioning

+

Page 121: Getting Your Toolbox Together

Vagrant - Provisioning

Configuration Management

Page 122: Getting Your Toolbox Together

Vagrant - Provisioning

Configuration Management•Infrastructure as code

Page 123: Getting Your Toolbox Together

Vagrant - Provisioning

Configuration Management•Infrastructure as code•Since it is code… VCS!

Page 124: Getting Your Toolbox Together

Vagrant - Provisioning

Various provisioning tools•Puppet•Chef•Ansible•Salt (requires gem)•Shell

Page 125: Getting Your Toolbox Together

Vagrant - Provisioning

Various provisioning tools•Puppet•Chef•Ansible•Salt (requires gem)•Shell

Page 126: Getting Your Toolbox Together

Chef

Page 127: Getting Your Toolbox Together

No Talk About Chef…

Page 128: Getting Your Toolbox Together

No Talk About Chef…

http://www.telegraph.co.uk/culture/qi/8735232/QI-Quite-interesting-facts-about-hats.html

Page 129: Getting Your Toolbox Together

Chef

Infrastructure Automation Framework

Page 130: Getting Your Toolbox Together

Chef

Infrastructure Automation Framework

•Chef Server

Page 131: Getting Your Toolbox Together

Chef

Infrastructure Automation Framework

•Chef Server•Chef Solo

Page 132: Getting Your Toolbox Together

Chef

Core Concepts

Page 133: Getting Your Toolbox Together

Chef

Core Concepts•Cookbooks

Page 134: Getting Your Toolbox Together

Chef

Core Concepts•Cookbooks•Roles

Page 135: Getting Your Toolbox Together

Chef - Cookbook

Fundamental Unit of Configuration and Policy Distribution in Chef

Page 136: Getting Your Toolbox Together

Chef - Cookbook

Fundamental Unit of Configuration and Policy Distribution in Chef

Or: Definition of how to install what and where it should be installed

Page 137: Getting Your Toolbox Together

Chef - Cookbook

Fundamental Unit of Configuration and Policy Distribution in Chef

Or: Definition of how to install what and where it should be installed

http://community.opscode.com/cookbooks

Page 138: Getting Your Toolbox Together

Chef - Cookbook

StructureCookbook/

/attributes

/recipes

/templates

Page 139: Getting Your Toolbox Together

Chef - Cookbook

StructureCookbook/

/attributes

/recipes

/templates

Attributes: parameters

Page 140: Getting Your Toolbox Together

Chef - Cookbook

StructureCookbook/

/attributes

/recipes

/templates

Attributes: parametersRecipes: code that needs to be executed

Page 141: Getting Your Toolbox Together

Chef - Cookbook

StructureCookbook/

/attributes

/recipes

/templates

Attributes: parametersRecipes: code that needs to be executedTemplates

Page 142: Getting Your Toolbox Together

Chef - Role

A way to define certain patterns and processes that exist across nodes in a Chef organization as belonging to a single job function.

Page 143: Getting Your Toolbox Together

Chef - Role

A way to define certain patterns and processes that exist across nodes in a Chef organization as belonging to a single job function.

Or: A collection of cookbooks and attributes that should be used

Page 144: Getting Your Toolbox Together

Chef - Role

• Simple json file• Name• Default Attributes• Override Attributes• Run List

Page 145: Getting Your Toolbox Together

Chef - Role

Allows for per environment configuration of setup.

As example, a basic example of Apache, php and mysql

Page 146: Getting Your Toolbox Together

Chef - Role - Example

{

"name": "development",

"default_attributes": { },

"override_attributes": { },

"run_list": [

"recipe[apache2]",

"recipe[apache2::mod_php5]",

"recipe[php]",

"recipe[mysql]”,

]

}

Page 147: Getting Your Toolbox Together

Vagrant & Chef

Page 148: Getting Your Toolbox Together

Vagrant - Chef

Page 149: Getting Your Toolbox Together

Vagrant - Chef

config.vm.provision :chef_solo do |chef|

chef.cookbooks_path = "deploy/chef/cookbooks"

chef.roles_path = "deploy/chef/roles"

chef.add_role('development')

end

Page 150: Getting Your Toolbox Together

Vagrant - Chef

What have we got so far?

Page 151: Getting Your Toolbox Together

Vagrant - Chef

What have we got so far?

Page 152: Getting Your Toolbox Together

Vagrant - Chef

What have we got so far?

•Consistent virtual machine with known OS

Page 153: Getting Your Toolbox Together

Vagrant - Chef

What have we got so far?

•Consistent virtual machine with known OS•Standardized stack for all developers

Page 154: Getting Your Toolbox Together

Vagrant - Chef

What have we got so far?

•Consistent virtual machine with known OS•Standardized stack for all developers

Where to keep it?

Page 155: Getting Your Toolbox Together

Vagrant - Chef

What have we got so far?

•Consistent virtual machine with known OS•Standardized stack for all developers

Where to keep it?Inside your project!

Page 156: Getting Your Toolbox Together

Vagrant - Chef

Custom Cookbooks

Page 157: Getting Your Toolbox Together

Vagrant - Chef

Custom Cookbooks

•Database

Page 158: Getting Your Toolbox Together

Vagrant - Chef

Custom Cookbooks

•Database•Fixtures

Page 159: Getting Your Toolbox Together

Vagrant - Chef

Custom Cookbooks

•Database•Fixtures•File generation

Page 160: Getting Your Toolbox Together

Remember This?

Page 161: Getting Your Toolbox Together

Welcome Aboard (Tooling Style)

• Step 1: get the code from VCS• Step 2: copy configuration sample• Step 3: run “vagrant up”• Step 4: ???

Page 162: Getting Your Toolbox Together

Welcome Aboard (Tooling Style)

• Step 1: get the code from VCS• Step 2: copy configuration sample• Step 3: run “vagrant up”• Step 4: there is no step 4

Page 163: Getting Your Toolbox Together

Vagrant - Chef

So, how to get started then?

$ git clone [email protected]:adent/42.git

$ cp ./deploy/dev/conf.yaml.sample \

./deploy/dev/conf.yaml

$ vagrant up

And ready to go!

Page 164: Getting Your Toolbox Together

Other Environments

Automated Deployment•Phing•Capistrano• Webistrano• Capifony

•Fabric•Vlad the Deployer•…

Page 165: Getting Your Toolbox Together

Other Environments

Run Tasks•Create Backup•Build / Update Environment•Deploy

Build / Update the Environment with the same tools you use for your dev env!

Page 166: Getting Your Toolbox Together

Other Environments

Building or Updating Environment not possible through tools?

Page 167: Getting Your Toolbox Together

Other Environments

Building or Updating Environment not possible through tools?

Configure your tools to reflect the production environment

Page 168: Getting Your Toolbox Together

Other Environments

Building or Updating Environment not possible through tools?

Configure your tools to reflect the production environment•Version locking•Recreate the production environment

Page 169: Getting Your Toolbox Together

Shameless Plug

Deploying your apps… the right way! Robbert van den Bogerd 13:30, track 2

Page 170: Getting Your Toolbox Together

Recap

Page 171: Getting Your Toolbox Together

Recap

• Use Development Images

Page 172: Getting Your Toolbox Together

Recap

• Use Development Images• Takes time to set up, but pays off in the

long run

Page 173: Getting Your Toolbox Together

Recap

• Use Development Images• Takes time to set up, but pays off in the

long run

• Automate Deployment

Page 174: Getting Your Toolbox Together

Recap

• Use Development Images• Takes time to set up, but pays off in the

long run

• Automate Deployment• Use Provisioning for every Environment

Page 175: Getting Your Toolbox Together
Page 176: Getting Your Toolbox Together

Further Reading

Documentation•http://www.vagrantup.com•http://opscode.com/chef/

Resources•http://community.opscode.com/cookbooks•http://www.vagrantbox.es

Page 177: Getting Your Toolbox Together

Thank You!

Feedback? Please let me know:

@DRvanR https://joind.in/8453

See you at the Conference Social!