Slide 1

Slide 1 text

No content

Slide 2

Slide 2 text

whoami ● Brazilian, living in Amsterdam since 2012 ● PHP developer and eventually sysadmin ● Author of Vagrant Cookbook on LeanPub

Slide 3

Slide 3 text

What to expect from this talk 1)Quick Vagrant overview 2)Provisioner Tasting: Ansible, Puppet and Chef 3)Useful Resources 4)What's new

Slide 4

Slide 4 text

No content

Slide 5

Slide 5 text

Why Vagrant?

Slide 6

Slide 6 text

“It works on my machine” - every developer, ever.

Slide 7

Slide 7 text

Why Vagrant? ● Reproducible and portable development environment ● Enables easier code collaboration ● Backend env tests / benchmark ● Automation Tools learning and testing

Slide 8

Slide 8 text

No content

Slide 9

Slide 9 text

The simplest thing that does something Vagrant.configure("2") do |config| config.vm.box = "hashicorp/precise64" config.vm.provision "shell", inline: "echo Hello World!" end

Slide 10

Slide 10 text

DEMO

Slide 11

Slide 11 text

No content

Slide 12

Slide 12 text

1. Ansible ● Tasks, Playbooks, Roles ● Tasks are defined with YAML ● 3rd most used ● Modules Directory: Ansible Galaxy ● Requires installation of Ansible in the Host

Slide 13

Slide 13 text

1.1 A Task - name: Install Nginx apt: pkg=nginx state=latest

Slide 14

Slide 14 text

1.1 A Task - name: Install Nginx apt: pkg=nginx state=latest - name: Install PHP Packages apt: pkg={{ item }} state=latest with_items: - php5-fpm - php5-cli

Slide 15

Slide 15 text

1.2 A Playbook # playbook.yml --- - hosts: all sudo: true tasks: - name: Update apt-cache apt: update_cache=yes - name: Install Nginx and php5-fpm apt: pkg={{ item }} state=latest with_items: - nginx - php5-fpm

Slide 16

Slide 16 text

1.3 A Role . ├── playbook.yml └── roles ├── init │ └── tasks │ └── main.yml └── nginxphp ├── tasks │ └── main.yml └── templates └── vhost.tpl #playbook.yml --- - hosts: all sudo: true vars: doc_root: /vagrant/web roles: - init - nginxphp

Slide 17

Slide 17 text

1.4 Vagrantfile Vagrant.configure("2") do |config| config.vm.box = "hashicorp/precise64" config.vm.provision "ansible" do |ansible| ansible.playbook = "playbook.yml" end end

Slide 18

Slide 18 text

No content

Slide 19

Slide 19 text

2. Puppet (puppet-apply) ● Resources, Manifests, Modules ● Non-sequential execution order ● Custom language based on Ruby ● 1st most used ● Modules Directory: Puppet Forge

Slide 20

Slide 20 text

2.1 A Resource package { 'nginx': ensure => 'installed' }

Slide 21

Slide 21 text

2.1 A Resource package { 'nginx': ensure => 'installed' } package { ['php5-fpm', 'php5-cli']: ensure => 'installed' }

Slide 22

Slide 22 text

2.2 A Manifest # manifests/default.pp exec { 'apt-get update': command => 'apt-get update' } package { ['nginx', 'php5-fpm']: ensure => 'installed', require => Exec['apt-get update'] }

Slide 23

Slide 23 text

2.3 A Module . ├── manifests │ └── default.pp └── modules └── nginxphp ├── manifests │ └── init.pp └── templates └── vhost.erb # manifests/default.pp exec { 'apt-get update': command => 'apt-get update', before => Class['nginxphp'], } class { 'nginxphp': doc_root => '/vagrant/web', }

Slide 24

Slide 24 text

2.4 Vagrantfile Vagrant.configure("2") do |config| config.vm.box = "hashicorp/precise64" config.vm.provision :puppet do |puppet| puppet.module_path = "modules" end end

Slide 25

Slide 25 text

No content

Slide 26

Slide 26 text

3. Chef (chef_solo) ● Resources, Recipes, Cookbooks ● Resources defined with Ruby ● 2nd most used, 1st with Ruby devs ● Modules Directory: Cookbooks ● Complex but very powerful

Slide 27

Slide 27 text

3.1 A Resource apt_package "nginx" do action :install end

Slide 28

Slide 28 text

3.1 A Resource apt_package "nginx" do action :install end ["nginx", "php5-fpm"].each do |p| apt_package p do action :install end end

Slide 29

Slide 29 text

3.2 A Recipe # cookbooks/main/recipes/default.rb execute "apt-get update" do command "apt-get update" end ["nginx", "php5-fpm"].each do |p| apt_package p do action :install end end

Slide 30

Slide 30 text

3.3 A Cookbook . └── cookbooks ├── main │ └── recipes │ └── default.rb └── nginxphp ├── recipes │ └── default.rb └── templates └── default └── vhost.erb # cookbooks/main/recipes/default.rb execute "apt-get update" do command "apt-get update" end include_recipe 'nginxphp'

Slide 31

Slide 31 text

3.4 Vagrantfile Vagrant.configure("2") do |config| config.vm.box = "hashicorp/precise64" config.vm.provision "chef_solo" do |chef| chef.add_recipe "main" end end

Slide 32

Slide 32 text

No content

Slide 33

Slide 33 text

Some Cool New Features

Slide 34

Slide 34 text

No content

Slide 35

Slide 35 text

Vagrant Share Demo

Slide 36

Slide 36 text

No content

Slide 37

Slide 37 text

Global status and control

Slide 38

Slide 38 text

Useful Resources

Slide 39

Slide 39 text

No content

Slide 40

Slide 40 text

No content

Slide 41

Slide 41 text

Vagrant Cookbook Special discount coupon for PhpDay http://bit.ly/vc-phpday

Slide 42

Slide 42 text

Questions?

Slide 43

Slide 43 text

https://joind.in/11299

Slide 44

Slide 44 text

No content

Slide 45

Slide 45 text

6.1 Debugging ● Unknown Vagrant error – Use VirtualBox / Vmware GUI ● Unknown Provisioner error – Increase provisioner verbosity ● Not working as expected – Login, fix, automate

Slide 46

Slide 46 text

6.2 NFS Performance ● Synchronization has a cost ● Symfony cache/logs – Too much writing operations on disk – We don't need this in our synced folder

Slide 47

Slide 47 text

No content

Slide 48

Slide 48 text

No content

Slide 49

Slide 49 text

No content