minicurso de vagrant
DESCRIPTION
Minicurso de Vagrant ministrado na 4ª Semana de Ciência da Computação e Tecnologia da Informação (SCTI 2014) - Campos - RJ - Link dos arquivos: https://github.com/LeandroSNunes/mini-curso-vagrantTRANSCRIPT
![Page 1: Minicurso de Vagrant](https://reader034.vdocuments.mx/reader034/viewer/2022042602/559c1d4b1a28abce298b45af/html5/thumbnails/1.jpg)
VAGRANT
Agilizando seu ambiente de desenvolvimento
Minicurso
![Page 2: Minicurso de Vagrant](https://reader034.vdocuments.mx/reader034/viewer/2022042602/559c1d4b1a28abce298b45af/html5/thumbnails/2.jpg)
@leandrosnunes
Leandro Nunes http://leandronunes.com
![Page 3: Minicurso de Vagrant](https://reader034.vdocuments.mx/reader034/viewer/2022042602/559c1d4b1a28abce298b45af/html5/thumbnails/3.jpg)
$ for name in {vagrant,git,vim,vboxmanage} ; do which $name ; done
Pré-requisito
![Page 4: Minicurso de Vagrant](https://reader034.vdocuments.mx/reader034/viewer/2022042602/559c1d4b1a28abce298b45af/html5/thumbnails/4.jpg)
O QUE É NECESSÁRIO PARA INICIAR UM PROJETO?
![Page 5: Minicurso de Vagrant](https://reader034.vdocuments.mx/reader034/viewer/2022042602/559c1d4b1a28abce298b45af/html5/thumbnails/5.jpg)
TODOS FAZEM INSTALAÇÕES LOCAIS
![Page 6: Minicurso de Vagrant](https://reader034.vdocuments.mx/reader034/viewer/2022042602/559c1d4b1a28abce298b45af/html5/thumbnails/6.jpg)
FERRAMENTA PARA CONSTRUIR E DISTRIBUIR AMBIENTES DE FORMA SIMPLES
VAGRANT
![Page 7: Minicurso de Vagrant](https://reader034.vdocuments.mx/reader034/viewer/2022042602/559c1d4b1a28abce298b45af/html5/thumbnails/7.jpg)
Mitchell Hashimoto @mitchellh
• Inicio em 2010 • Desenvolvido em Ruby • Release 1.6.5 • HashiCorp 2012
![Page 8: Minicurso de Vagrant](https://reader034.vdocuments.mx/reader034/viewer/2022042602/559c1d4b1a28abce298b45af/html5/thumbnails/8.jpg)
O QUE É PRECISO PARA UTILIZAR O VAGRANT?
![Page 9: Minicurso de Vagrant](https://reader034.vdocuments.mx/reader034/viewer/2022042602/559c1d4b1a28abce298b45af/html5/thumbnails/9.jpg)
PROVIDER Gerenciador de Máquinas Virtuais
UMA MÁQUINA HOST Maquina para instalar o vagrant – Máquina de Desenvolvimento
VAGRANT www.vagrantup.com
![Page 10: Minicurso de Vagrant](https://reader034.vdocuments.mx/reader034/viewer/2022042602/559c1d4b1a28abce298b45af/html5/thumbnails/10.jpg)
PROVIDER
OU OU
DEFAULT OU
OU
![Page 11: Minicurso de Vagrant](https://reader034.vdocuments.mx/reader034/viewer/2022042602/559c1d4b1a28abce298b45af/html5/thumbnails/11.jpg)
Download em:
www.vagrantup.com www.virtualbox.org
![Page 12: Minicurso de Vagrant](https://reader034.vdocuments.mx/reader034/viewer/2022042602/559c1d4b1a28abce298b45af/html5/thumbnails/12.jpg)
Fonte: http://www.vcritical.com/
GUEST
HOST
![Page 13: Minicurso de Vagrant](https://reader034.vdocuments.mx/reader034/viewer/2022042602/559c1d4b1a28abce298b45af/html5/thumbnails/13.jpg)
$ vBoxManage
![Page 14: Minicurso de Vagrant](https://reader034.vdocuments.mx/reader034/viewer/2022042602/559c1d4b1a28abce298b45af/html5/thumbnails/14.jpg)
$ mkdir mini-curso-vagrant $ cd mini-curso-vagrant
![Page 15: Minicurso de Vagrant](https://reader034.vdocuments.mx/reader034/viewer/2022042602/559c1d4b1a28abce298b45af/html5/thumbnails/15.jpg)
$ vagrant init vagrant init [box-name] [box-url]
![Page 16: Minicurso de Vagrant](https://reader034.vdocuments.mx/reader034/viewer/2022042602/559c1d4b1a28abce298b45af/html5/thumbnails/16.jpg)
VagrantFile
VAGRANTFILE_API_VERSION = "2” Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "base”end
![Page 17: Minicurso de Vagrant](https://reader034.vdocuments.mx/reader034/viewer/2022042602/559c1d4b1a28abce298b45af/html5/thumbnails/17.jpg)
BOX
REPRESENTA UM SISTEMA OPERACIONAL INSTALADO PARA UM PROVIDER ESPECÍFICO.
![Page 18: Minicurso de Vagrant](https://reader034.vdocuments.mx/reader034/viewer/2022042602/559c1d4b1a28abce298b45af/html5/thumbnails/18.jpg)
BOX BASE vagrantbox.es
vagrantcloud.com
![Page 19: Minicurso de Vagrant](https://reader034.vdocuments.mx/reader034/viewer/2022042602/559c1d4b1a28abce298b45af/html5/thumbnails/19.jpg)
$ vagrant init leandrosnunes/precise64
![Page 20: Minicurso de Vagrant](https://reader034.vdocuments.mx/reader034/viewer/2022042602/559c1d4b1a28abce298b45af/html5/thumbnails/20.jpg)
VAGRANTFILE_API_VERSION = "2” Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| config.vm.box = ”leandrosnunes/precise64”end
VagrantFile
![Page 21: Minicurso de Vagrant](https://reader034.vdocuments.mx/reader034/viewer/2022042602/559c1d4b1a28abce298b45af/html5/thumbnails/21.jpg)
$ vagrant box add ADDRESS
$ vagrant box list
![Page 22: Minicurso de Vagrant](https://reader034.vdocuments.mx/reader034/viewer/2022042602/559c1d4b1a28abce298b45af/html5/thumbnails/22.jpg)
$ vagrant up
![Page 23: Minicurso de Vagrant](https://reader034.vdocuments.mx/reader034/viewer/2022042602/559c1d4b1a28abce298b45af/html5/thumbnails/23.jpg)
![Page 24: Minicurso de Vagrant](https://reader034.vdocuments.mx/reader034/viewer/2022042602/559c1d4b1a28abce298b45af/html5/thumbnails/24.jpg)
VM RODANDO NO VIRTUALBOX
![Page 25: Minicurso de Vagrant](https://reader034.vdocuments.mx/reader034/viewer/2022042602/559c1d4b1a28abce298b45af/html5/thumbnails/25.jpg)
![Page 26: Minicurso de Vagrant](https://reader034.vdocuments.mx/reader034/viewer/2022042602/559c1d4b1a28abce298b45af/html5/thumbnails/26.jpg)
$ vagrant ssh
![Page 27: Minicurso de Vagrant](https://reader034.vdocuments.mx/reader034/viewer/2022042602/559c1d4b1a28abce298b45af/html5/thumbnails/27.jpg)
$ vagrant halt
![Page 28: Minicurso de Vagrant](https://reader034.vdocuments.mx/reader034/viewer/2022042602/559c1d4b1a28abce298b45af/html5/thumbnails/28.jpg)
$ vagrant init $ vagrant box $ vagrant up $ vagrant ssh$ vagrant halt
![Page 29: Minicurso de Vagrant](https://reader034.vdocuments.mx/reader034/viewer/2022042602/559c1d4b1a28abce298b45af/html5/thumbnails/29.jpg)
EFETUAR TESTES DE NOVAS FERRAMENTAS
![Page 30: Minicurso de Vagrant](https://reader034.vdocuments.mx/reader034/viewer/2022042602/559c1d4b1a28abce298b45af/html5/thumbnails/30.jpg)
$ vagrant up
$ vagrant ssh
$ sudo apt-get update
$ sudo apt-get –y install postgresql
$ sudo apt-get –y install nginx
$ sudo apt-get –y install php
$ sudo apt-get –y uninstall php
$ sudo apt-get –y install ruby
![Page 31: Minicurso de Vagrant](https://reader034.vdocuments.mx/reader034/viewer/2022042602/559c1d4b1a28abce298b45af/html5/thumbnails/31.jpg)
$ vagrant up
$ vagrant ssh
$ sudo apt-get update
$ which nginx
$ sudo apt-get –y install nginx
$ which nginx
![Page 32: Minicurso de Vagrant](https://reader034.vdocuments.mx/reader034/viewer/2022042602/559c1d4b1a28abce298b45af/html5/thumbnails/32.jpg)
$ vagrant status
![Page 33: Minicurso de Vagrant](https://reader034.vdocuments.mx/reader034/viewer/2022042602/559c1d4b1a28abce298b45af/html5/thumbnails/33.jpg)
$ vagrant destroy
![Page 34: Minicurso de Vagrant](https://reader034.vdocuments.mx/reader034/viewer/2022042602/559c1d4b1a28abce298b45af/html5/thumbnails/34.jpg)
$ vagrant up
![Page 35: Minicurso de Vagrant](https://reader034.vdocuments.mx/reader034/viewer/2022042602/559c1d4b1a28abce298b45af/html5/thumbnails/35.jpg)
MEU IDE PREFERIDO SÓ FUNCIONA NO WINDOWS!
![Page 36: Minicurso de Vagrant](https://reader034.vdocuments.mx/reader034/viewer/2022042602/559c1d4b1a28abce298b45af/html5/thumbnails/36.jpg)
AS MODIFICAÇÕES SÃO REFLETIDAS EM TEMPO REAL ENTRE AS MAQUINAS HOST E GUEST
SYNCED FOLDERS
![Page 37: Minicurso de Vagrant](https://reader034.vdocuments.mx/reader034/viewer/2022042602/559c1d4b1a28abce298b45af/html5/thumbnails/37.jpg)
$ echo "Mini Curso de Vagrant" > hello_world.txt $ cat hello_world.txt $ vagrant ssh $ cd /vagrant $ ls $ cat hello_world.txt
![Page 38: Minicurso de Vagrant](https://reader034.vdocuments.mx/reader034/viewer/2022042602/559c1d4b1a28abce298b45af/html5/thumbnails/38.jpg)
COMO ACESSAR A APLICAÇÃO?
![Page 39: Minicurso de Vagrant](https://reader034.vdocuments.mx/reader034/viewer/2022042602/559c1d4b1a28abce298b45af/html5/thumbnails/39.jpg)
UMA REDE NAT É CRIADA POR DEFAULT. A REDE PRIVADA PERMITE ACESSO DE OUTROS DISPOSITIVOS NA MESMA REDE.
NETWORK
![Page 40: Minicurso de Vagrant](https://reader034.vdocuments.mx/reader034/viewer/2022042602/559c1d4b1a28abce298b45af/html5/thumbnails/40.jpg)
$ vagrant destroy $ cd ../ $ rm –r mini-curso-vagrant $ git clone [email protected]:LeandroSNunes/mini-curso-vagrant.git $ cd mini-curso-vagrant $ git fetch origin step1 $ git checkout step1 $ git commit –am “update”
![Page 41: Minicurso de Vagrant](https://reader034.vdocuments.mx/reader034/viewer/2022042602/559c1d4b1a28abce298b45af/html5/thumbnails/41.jpg)
VagrantFile
config.vm.network :private_network, ip: "192.168.33.30”config.vm.network :forwarded_port, guest: 3000, host: 3000config.vm.network :forwarded_port, guest: 3306, host: 3306config.vm.post_up_message = ”Mini curso de vagrant\n IP: 192.168.33.30"
![Page 42: Minicurso de Vagrant](https://reader034.vdocuments.mx/reader034/viewer/2022042602/559c1d4b1a28abce298b45af/html5/thumbnails/42.jpg)
$ vagrant up
$ vagrant ssh
$ sudo apt-get update
$ sudo apt-get –y install nginx
$ sudo service nginx start
![Page 43: Minicurso de Vagrant](https://reader034.vdocuments.mx/reader034/viewer/2022042602/559c1d4b1a28abce298b45af/html5/thumbnails/43.jpg)
Acessando o nginx
![Page 44: Minicurso de Vagrant](https://reader034.vdocuments.mx/reader034/viewer/2022042602/559c1d4b1a28abce298b45af/html5/thumbnails/44.jpg)
$ vagrant package
![Page 45: Minicurso de Vagrant](https://reader034.vdocuments.mx/reader034/viewer/2022042602/559c1d4b1a28abce298b45af/html5/thumbnails/45.jpg)
AMBIENTE DE DESENVOLVIMENTO IGUAL PARA TODO TIME
![Page 46: Minicurso de Vagrant](https://reader034.vdocuments.mx/reader034/viewer/2022042602/559c1d4b1a28abce298b45af/html5/thumbnails/46.jpg)
Postgresql
Nginx Puma
Assets
![Page 47: Minicurso de Vagrant](https://reader034.vdocuments.mx/reader034/viewer/2022042602/559c1d4b1a28abce298b45af/html5/thumbnails/47.jpg)
Postgresql Nginx Puma
Assets
![Page 48: Minicurso de Vagrant](https://reader034.vdocuments.mx/reader034/viewer/2022042602/559c1d4b1a28abce298b45af/html5/thumbnails/48.jpg)
1 Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| 2 config.vm.box = "leandrosnunes/precise64" 3 4 config.vm.define :development do |dev| 5 dev.vm.network "private_network", ip: "192.168.33.30" 6 dev.vm.network :forwarded_port, guest: 3306, host: 3306 # mysql 7 8 dev.vm.post_up_message = "Dev mini curso de vagrant\n IP: 192.168.33.30" 9 end10 11 config.vm.define :production do |pro|12 pro.vm.network "private_network", ip: "192.168.33.31"13 14 pro.vm.post_up_message = "Prod mini curso de vagrant\n IP: 192.168.33.31"15 end16 end
![Page 49: Minicurso de Vagrant](https://reader034.vdocuments.mx/reader034/viewer/2022042602/559c1d4b1a28abce298b45af/html5/thumbnails/49.jpg)
$ vagrant up
$ vagrant up development
$ vagrant up production
$ vagrant ssh
$ vagrant ssh development
$ vagrant ssh production
![Page 50: Minicurso de Vagrant](https://reader034.vdocuments.mx/reader034/viewer/2022042602/559c1d4b1a28abce298b45af/html5/thumbnails/50.jpg)
$ vagrant destroy
$ vagrant destroy development
$ vagrant destroy production
$ vagrant halt
$ vagrant halt development
$ vagrant halt production
![Page 51: Minicurso de Vagrant](https://reader034.vdocuments.mx/reader034/viewer/2022042602/559c1d4b1a28abce298b45af/html5/thumbnails/51.jpg)
A APLICAÇÃO PODE RODAR EM AMBIENTE SIMILAR AO DE PRODUÇÃO
![Page 52: Minicurso de Vagrant](https://reader034.vdocuments.mx/reader034/viewer/2022042602/559c1d4b1a28abce298b45af/html5/thumbnails/52.jpg)
ACABA COM A FRASE
“FUNCIONA NA MINHA MÁQUINA”
![Page 53: Minicurso de Vagrant](https://reader034.vdocuments.mx/reader034/viewer/2022042602/559c1d4b1a28abce298b45af/html5/thumbnails/53.jpg)
1 Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| 2 config.vm.box = "leandrosnunes/precise64" 3 4 config.vm.define :development do |dev| 5 dev.vm.network "private_network", ip: "192.168.33.30" 6 dev.vm.network :forwarded_port, guest: 3306, host: 3306 # mysql 7 8 dev.vm.provider "virtualbox" do |vb| 9 vb.customize ["modifyvm", :id, "--memory", "1024"]10 vb.customize ["modifyvm", :id, "--cpus", "1"]11 end12 13 dev.vm.post_up_message = "Dev mini curso de vagrant\n IP: 192.168.33.30"14 end15 16 config.vm.define :production do |pro|17 pro.vm.network "private_network", ip: "192.168.33.31"18 19 pro.vm.provider "virtualbox" do |vb|20 vb.customize ["modifyvm", :id, "--memory", "1024"]21 vb.customize ["modifyvm", :id, "--cpus", "2"]22 end23 24 pro.vm.post_up_message = "Prod mini curso de vagrant\n IP: 192.168.33.31"25 end26 end
![Page 54: Minicurso de Vagrant](https://reader034.vdocuments.mx/reader034/viewer/2022042602/559c1d4b1a28abce298b45af/html5/thumbnails/54.jpg)
TAREFAS MANUAIS NÃO PERMITEM QUALIDADE
![Page 55: Minicurso de Vagrant](https://reader034.vdocuments.mx/reader034/viewer/2022042602/559c1d4b1a28abce298b45af/html5/thumbnails/55.jpg)
ANSIBLE CHEF PUPPET SHELL
PROVISIONER
![Page 56: Minicurso de Vagrant](https://reader034.vdocuments.mx/reader034/viewer/2022042602/559c1d4b1a28abce298b45af/html5/thumbnails/56.jpg)
development 1 dev.vm.provision :puppet do |puppet|2 puppet.module_path = "modules"3 puppet.manifest_file = "development.pp"4 puppet.options = "--verbose --debug"5 end
production 1 pro.vm.provision :puppet do |puppet|2 puppet.module_path = "modules"3 puppet.manifest_file = "production.pp"4 end
![Page 57: Minicurso de Vagrant](https://reader034.vdocuments.mx/reader034/viewer/2022042602/559c1d4b1a28abce298b45af/html5/thumbnails/57.jpg)
$ vagrant up development
$ vagrant up production
![Page 58: Minicurso de Vagrant](https://reader034.vdocuments.mx/reader034/viewer/2022042602/559c1d4b1a28abce298b45af/html5/thumbnails/58.jpg)
$ vagrant provision
![Page 59: Minicurso de Vagrant](https://reader034.vdocuments.mx/reader034/viewer/2022042602/559c1d4b1a28abce298b45af/html5/thumbnails/59.jpg)
$ vagrant reload --provision
![Page 60: Minicurso de Vagrant](https://reader034.vdocuments.mx/reader034/viewer/2022042602/559c1d4b1a28abce298b45af/html5/thumbnails/60.jpg)
GERÊNCIA DE CONFIGURAÇÃO
![Page 61: Minicurso de Vagrant](https://reader034.vdocuments.mx/reader034/viewer/2022042602/559c1d4b1a28abce298b45af/html5/thumbnails/61.jpg)
INCENTIVO PARA PRÁTICAS DO MOVIMENTO DEVOPS
![Page 62: Minicurso de Vagrant](https://reader034.vdocuments.mx/reader034/viewer/2022042602/559c1d4b1a28abce298b45af/html5/thumbnails/62.jpg)
PARTICIPAR DE PROJETOS COM PECULIARIDADES DIFERENTES
![Page 63: Minicurso de Vagrant](https://reader034.vdocuments.mx/reader034/viewer/2022042602/559c1d4b1a28abce298b45af/html5/thumbnails/63.jpg)
SIMPLICIDADE PARA CONTRIBUIR PARA PROJETOS OPEN SOURCE
![Page 64: Minicurso de Vagrant](https://reader034.vdocuments.mx/reader034/viewer/2022042602/559c1d4b1a28abce298b45af/html5/thumbnails/64.jpg)
FUNCIONALIDADES EXTRAS, COMO SUPORTE A OUTROS PROVIDERS
PLUGIN
![Page 65: Minicurso de Vagrant](https://reader034.vdocuments.mx/reader034/viewer/2022042602/559c1d4b1a28abce298b45af/html5/thumbnails/65.jpg)
$ vagrant install plugin vagrant-vbguest
$ vagrant install vagrant-librarian-puppet
![Page 66: Minicurso de Vagrant](https://reader034.vdocuments.mx/reader034/viewer/2022042602/559c1d4b1a28abce298b45af/html5/thumbnails/66.jpg)
VagrantFile
config.vm.synced_folder ".", "/vagrant", type: "nfs"
![Page 67: Minicurso de Vagrant](https://reader034.vdocuments.mx/reader034/viewer/2022042602/559c1d4b1a28abce298b45af/html5/thumbnails/67.jpg)
![Page 68: Minicurso de Vagrant](https://reader034.vdocuments.mx/reader034/viewer/2022042602/559c1d4b1a28abce298b45af/html5/thumbnails/68.jpg)
VAGRANT OPEN SOURCE
Github: https://github.com/mitchellh/vagrant IRC: #vagrant Google Groups: vagrant-up
![Page 69: Minicurso de Vagrant](https://reader034.vdocuments.mx/reader034/viewer/2022042602/559c1d4b1a28abce298b45af/html5/thumbnails/69.jpg)
VAGRANT DOCS
http://docs.vagrantup.com/v2/
![Page 70: Minicurso de Vagrant](https://reader034.vdocuments.mx/reader034/viewer/2022042602/559c1d4b1a28abce298b45af/html5/thumbnails/70.jpg)
?