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
580
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
Criando Container Runtimes mais Seguras com Wolfi
erikaheidi
0
51
Introducing Chainguard Images for Safer PHP Runtimes
erikaheidi
0
100
Automatizando documentação em PHP com Autodocs
erikaheidi
0
62
Building the World: The Story Behind Wolfi
erikaheidi
0
420
Hello Wolfi
erikaheidi
1
620
Container Images for the Cloud Native Era
erikaheidi
1
310
Creating Secure Container Images with apko
erikaheidi
0
420
Criando GitHub Actions em PHP com Minicli
erikaheidi
0
180
Building GitHub Actions in PHP with Minicli
erikaheidi
0
480
Other Decks in Programming
See All in Programming
ピグパーティにおけるMongoDB CommunityバージョンからAtlasへの移行事例
10969hotaka
0
130
Async Await: Mastering Python's Time-Bending Tricks - EuroPython2024
yanbo
1
290
Rust.Nagoya #1
codemountains
0
170
CSC307 Lecture 13
javiergs
PRO
0
150
なぜ宣言的 UI は壊れにくいのか / Why declarative UI is less fragile
uenitty
29
13k
継続的な活動で築く地方エンジニアの道
myamashii
2
360
Cloudflare Workers x AWS Lambdaの組み合わせユースケース / Cloudflare Workers x AWS Lambda Combination Use Case
seike460
PRO
2
310
Javaの現状2024夏 / Java current status 2024 summer
kishida
4
1.4k
Rustのweb開発を助ける 便利なツール紹介
yuki0418
1
190
開発部に不満を持っていたCSがエンジニアにジョブチェンしてわかった「勝手に諦めない」ことの大切さ
sakuraikotone
28
16k
企業向け生成AIアプリの 開発から得られた知見
takaakikakei
0
310
Webエディタライブラリ 「CodeMirror」から学ぶ Webアプリ開発のテクニック
ryosukeigarashi
0
250
Featured
See All Featured
A better future with KSS
kneath
231
17k
What's new in Ruby 2.0
geeforr
338
31k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
13
430
XXLCSS - How to scale CSS and keep your sanity
sugarenia
245
1.2M
Mobile First: as difficult as doing things right
swwweet
219
8.8k
Visualization
eitanlees
139
14k
10 Git Anti Patterns You Should be Aware of
lemiorhan
652
58k
Debugging Ruby Performance
tmm1
71
11k
The Pragmatic Product Professional
lauravandoore
29
6.1k
Bash Introduction
62gerente
607
210k
The World Runs on Bad Software
bkeepers
PRO
63
11k
How to train your dragon (web standard)
notwaldorf
79
5.5k
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