Slide 1

Slide 1 text

Let’s automate! Artūras Šmorgun, VilniusPHP#6

Slide 2

Slide 2 text

Me Software Engineer Inviqa Group (Inviqa + Session Digital + SensioLabs UK)

Slide 3

Slide 3 text

Git, Apache, PHP, MySQL... Common environment

Slide 4

Slide 4 text

Local Used by 50% attendees 50% 50% Local environment Other

Slide 5

Slide 5 text

Advantages Fast Easy Comfortable

Slide 6

Slide 6 text

Disadvantages Not flexible Very different from production (usually) Team members’ environments are different

Slide 7

Slide 7 text

What have we got? Fast, easy, comfortable environment. What if it would be more similar to production?

Slide 8

Slide 8 text

“Golden” VM Used by 10% attendees 40% 10% 50% Local environment Virtual machine Other

Slide 9

Slide 9 text

Advantages More similar to production (usually) More flexible Works same way on different OS Team members use same environment

Slide 10

Slide 10 text

Virtualbox Oracle product Open source Free Works under Windows, Linux, Mac, Solaris Can host Windows, Linux, Mac, Solaris, ...

Slide 11

Slide 11 text

Installation Google: “virtualbox download” Download Install (next > next > next) Start

Slide 12

Slide 12 text

Creating VM New machine with new virtual disk Install OS Install Guest Additions Configure shares Install Apache, PHP, MySQL Done :)

Slide 13

Slide 13 text

Disadvantages More steps to reproduce Uses more resources Slower (sometimes) Usually is copied between projects Not easy to distribute

Slide 14

Slide 14 text

What have we got? Fast, easy, comfortable environment, similar to production and flexible. What if it would be easier to distribute?

Slide 15

Slide 15 text

Vagrant Software for creating and configuring virtual development environments.

Slide 16

Slide 16 text

What is it? Console tool Written in Ruby With integrated VirtualBox integration Vmware integration (via plugin) Cloud integration (via plugins)

Slide 17

Slide 17 text

Advantages Automated environment distribution Ready to use templates in the internet Environment setup is code Easier to manage several projects Easier to create complex environment

Slide 18

Slide 18 text

How it works? It uses Baseboxes to create Virtual Machines via configuration in Vagrantfile

Slide 19

Slide 19 text

Installation Google: “vagrant download” Download Install (next > next > next) Done :)

Slide 20

Slide 20 text

Commands vagrant init vagrant up && vagrant halt vagrant suspend && vagrant resume vagrant restart vagrant destroy

Slide 21

Slide 21 text

Configuration vagrant provision --no-provision Shell provisioning

Slide 22

Slide 22 text

What have we got? Fast, easy, comfortable environment, similar to production and flexible. Easy to distribute. What if it would be easier to setup VM?

Slide 23

Slide 23 text

Chef Solo Configuration management tool.

Slide 24

Slide 24 text

Chef Solo Version of Chef, perfect for managing single machine (per project, per environment).

Slide 25

Slide 25 text

What is it? Console tool Written in Ruby Open source by Opscode

Slide 26

Slide 26 text

Advantages Configuration as a code Easy to reproduce Easy to store Loads of ready to use recipies

Slide 27

Slide 27 text

How it works? Uses Cookbooks & Recipes. Vagrant starts chef provisioning. Chef provisions defined recipes. Recipes configures environment.

Slide 28

Slide 28 text

Installation (deb) Add opscode repository echo "deb http://apt.opscode.com/ `lsb_release -cs`-0.10 main" | sudo tee /etc/apt/sources.list.d/opscode.list Add GPG key sudo mkdir -p /etc/apt/trusted.gpg.d gpg --keyserver keys.gnupg.net --recv-keys 83EF826A Install package sudo apt-get update && sudo apt-get install chef

Slide 29

Slide 29 text

What have we got? Fast, easy, comfortable environment, similar to production and flexible. Easy to distribute, with configuration as a code. What if it would be easier to manage cookbook dependencies?

Slide 30

Slide 30 text

Librarian Chef Framework for writing bundlers, which are tools that resolve, fetch, install, and isolate a project's dependencies.

Slide 31

Slide 31 text

Librarian Chef Bundler for Chef-based infrastructure repositories.

Slide 32

Slide 32 text

Advantages No need to maintain third party cookbooks No need to know have all the dependencies

Slide 33

Slide 33 text

How it works? It becomes source of public cookbooks Custom cookbooks goes to “site-cookbooks” Configuration in Cheffile Lock in Cheffile.lock

Slide 34

Slide 34 text

Installation Install RVM \curl -L https://get.rvm.io | bash -s stable --ruby -- autolibs=enable --auto-dotfiles Install package sudo gem install librarian-chef

Slide 35

Slide 35 text

Commands librarian-chef init librarian-chef install [--clean] [--verbose] librarian-chef show librarian-chef outdated [--verbose]

Slide 36

Slide 36 text

What have we got? Fast, easy, comfortable environment, similar to production and flexible. Easy to distribute, with configuration as a code. With cookbook dependency management. What if I wouldn’t need to rely on unknown baseboxes?

Slide 37

Slide 37 text

Veewee Tool for easily (and repeatedly) building virtual machine images.

Slide 38

Slide 38 text

Advantages VM creation via code No need to rely on baseboxes from the Internet Custom baseboxes

Slide 39

Slide 39 text

How it works? VM for KVM, Parallels, Virtualbox. Using Templates and Definitions. Builds and Validates. can Export.

Slide 40

Slide 40 text

Installation sudo gem install veewee

Slide 41

Slide 41 text

Commands veewee vbox templates veewee vbox define veewee vbox build veewee vbox verify veewee vbox export

Slide 42

Slide 42 text

Disadvantages Too complicates at times Now always what you need

Slide 43

Slide 43 text

Bento

Slide 44

Slide 44 text

What is it? Opscode product Only for VirtualBox

Slide 45

Slide 45 text

Advantages DRY modular baseboxes

Slide 46

Slide 46 text

How it works? Encapsulates Veewee Has several DRY Definitions prepared for use

Slide 47

Slide 47 text

Installation Clone bento from github git clone git://github.com/opscode/bento.git Install package cd bento && bundle install

Slide 48

Slide 48 text

Commands bundle exec veewee vbox list bundle exec veewee vbox build bundle exec veewee vbox build bundle exec veewee vbox export

Slide 49

Slide 49 text

What have we got? Fast, easy, comfortable environment, similar to production and flexible. Easy to distribute, with configuration as a code. With cookbook dependency management, custom built baseboxes. What if deployment would be more reliable too?

Slide 50

Slide 50 text

Chef Server A systems and cloud infrastructure automation framework, no matter the size of infrastructure.

Slide 51

Slide 51 text

Organization One or more dev workstation Single chef server Many nodes

Slide 52

Slide 52 text

Workstation Communicates with Chef Server Knife Recipe synchronization Organization policy configuration

Slide 53

Slide 53 text

Shef Server Hub for configuration data Cookbooks Policies Registered nodes metadata

Slide 54

Slide 54 text

Node (Chef Client) Maintained server Chef-client for configuring Ohai for system information

Slide 55

Slide 55 text

Capistrano Utility and framework for executing commands in parallel on multiple remote machines, via SSH.

Slide 56

Slide 56 text

What is it? Console tool Open Source Free Written in Ruby

Slide 57

Slide 57 text

Advantages Instant deployment to all machines Versioning of deployments Fast rollback

Slide 58

Slide 58 text

How it works? Capfile - definition Tasks - executes on servers Servers - 1..N Roles - may be unique per server

Slide 59

Slide 59 text

Installation sudo gem install capistrano

Slide 60

Slide 60 text

Commands capify cap cap -vT cap invoke COMMAND=”echo 'command'” SUDO=1 cap shell

Slide 61

Slide 61 text

What have we got? Fast, easy, comfortable environment, similar to production and flexible. Easy to distribute, with configuration as a code. With cookbook dependency management, custom built baseboxes. Automated deployment of infrastructure and code.

Slide 62

Slide 62 text

Links Virtualbox Vagrant Veewee / Bento Chef Librarian Capistrano

Slide 63

Slide 63 text

Questions? Artūras Šmorgun asmorgun@inviqa.com @asarturas

Slide 64

Slide 64 text

Thank you! Artūras Šmorgun asmorgun@inviqa.com @asarturas