Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Vagrant Provisioners in a Nutshell
Search
Erika Heidi
May 16, 2014
Programming
1
560
Vagrant Provisioners in a Nutshell
Presented at PhpDay Verona - 16/05/2014
Erika Heidi
May 16, 2014
Tweet
Share
More Decks by Erika Heidi
See All by Erika Heidi
Automatizando documentação em PHP com Autodocs
erikaheidi
0
26
Building the World: The Story Behind Wolfi
erikaheidi
0
290
Hello Wolfi
erikaheidi
1
580
Container Images for the Cloud Native Era
erikaheidi
1
260
Creating Secure Container Images with apko
erikaheidi
0
380
Criando GitHub Actions em PHP com Minicli
erikaheidi
0
150
Building GitHub Actions in PHP with Minicli
erikaheidi
0
430
10 Code Search Tricks for Open Source
erikaheidi
2
200
The Art of Programming - Laracon Online Winter 22
erikaheidi
0
340
Other Decks in Programming
See All in Programming
コードレビューで学ぶ!Kotlinオブジェクト指向デザインパターン
akkie76
2
180
GraphQLサーバの構成要素を整理する #ハッカー鮨 #tsukijigraphql / graphql server technology selection
izumin5210
1
200
⼤規模⾔語モデルの拡張(RAG)が 終わったかも知れない件について
nearme_tech
22
15k
品質とスピードを両立: TypeScriptの柔軟な型システムをバックエンドで活用する
kosui
8
2.2k
VSCodeでのDatabricks開発もお勧めしたい/I would also recommend Databricks development with VSCode.
kazumain
0
240
[技育CAMPアカデミア]アイディアを形に!【超入門】スマホアプリ開発〜リリースまでの流れをご紹介
teamlab
PRO
0
350
ONE WEDGE_company_guide
1wedge_one
0
380
0→1と1→10の狭間で Javaという技術選定を振り返る/Reflecting on the Decision to Choose Java Between Scaling from 0 to 1 and 1 to 10
jaguar_imo
2
370
SpringBoot+MyBatisで例外が出たときどこを見るか
syukai
0
110
CQRS/ES avec Symfony, c’est (trop) bien !
jeremyfreeagent
1
630
try! Swift Tokyo 2024のLT枠に採択されたプロポーザルを出すときに考えていたこと
ski
0
340
スクラムチームと認知負荷 - ニフティのスクラムトーク Vol2. / NIFTY Tech Talk #18
niftycorp
PRO
1
120
Featured
See All Featured
What the flash - Photography Introduction
edds
64
11k
Producing Creativity
orderedlist
PRO
336
39k
VelocityConf: Rendering Performance Case Studies
addyosmani
320
23k
Imperfection Machines: The Place of Print at Facebook
scottboms
258
12k
Designing with Data
zakiwarfel
95
4.8k
Designing for Performance
lara
601
67k
Robots, Beer and Maslow
schacon
PRO
155
7.9k
Building Better People: How to give real-time feedback that sticks.
wjessup
354
18k
The Power of CSS Pseudo Elements
geoffreycrofte
59
5k
Happy Clients
brianwarren
91
6.4k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
76
41k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
220
21k
Transcript
None
whoami • Brazilian, living in Amsterdam since 2012 • PHP
<independent> developer and eventually sysadmin • Author of Vagrant Cookbook on LeanPub
What to expect from this talk 1)Quick Vagrant overview 2)Provisioner
Tasting: Ansible, Puppet and Chef 3)Useful Resources 4)What's new
None
Why Vagrant?
“It works on my machine” - every developer, ever.
Why Vagrant? • Reproducible and portable development environment • Enables
easier code collaboration • Backend env tests / benchmark • Automation Tools learning and testing
None
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
DEMO
None
1. Ansible • Tasks, Playbooks, Roles • Tasks are defined
with YAML • 3rd most used • Modules Directory: Ansible Galaxy • Requires installation of Ansible in the Host
1.1 A Task - name: Install Nginx apt: pkg=nginx state=latest
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
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
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
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
None
2. Puppet (puppet-apply) • Resources, Manifests, Modules • Non-sequential execution
order • Custom language based on Ruby • 1st most used • Modules Directory: Puppet Forge
2.1 A Resource package { 'nginx': ensure => 'installed' }
2.1 A Resource package { 'nginx': ensure => 'installed' }
package { ['php5-fpm', 'php5-cli']: ensure => 'installed' }
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'] }
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', }
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
None
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
3.1 A Resource apt_package "nginx" do action :install end
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
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
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'
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
None
Some Cool New Features
None
Vagrant Share Demo
None
Global status and control
Useful Resources
None
None
Vagrant Cookbook Special discount coupon for PhpDay http://bit.ly/vc-phpday
Questions?
https://joind.in/11299
None
6.1 Debugging • Unknown Vagrant error – Use VirtualBox /
Vmware GUI • Unknown Provisioner error – Increase provisioner verbosity • Not working as expected – Login, fix, automate
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
None
None
None