+ All Categories

Vagrant

Date post: 06-May-2015
Category:
Upload: evans-ye
View: 621 times
Download: 0 times
Share this document with a friend
23
Vagrant
Transcript
Page 1: Vagrant

Vagrant

Page 2: Vagrant

04/11/2023 Copyright 2013 Trend Micro Inc.

Agenda

• Introduction to Vagrant

• Create VM

• Provisioning

• plugins

Page 3: Vagrant

04/11/2023 Copyright 2013 Trend Micro Inc.

Introduction

Page 4: Vagrant

04/11/2023 Copyright 2013 Trend Micro Inc.

Vagrant

• A open source command line VM provision tool

• MIT licence

• Still virtualization,but more easier, more flexible

• Support shell, puppet, chef on provisioning

Page 5: Vagrant

04/11/2023 Copyright 2013 Trend Micro Inc.

Easy to use and share

http://www.vagrantbox.es/http://puppet-vagrant-boxes.puppetlabs.com/

Page 6: Vagrant

04/11/2023 Copyright 2013 Trend Micro Inc.

• Install virtualbox– https://www.virtualbox.org/wiki/Downloads

• Install vagrant (support windows, mac, linux)– http://downloads.vagrantup.com/tags/v1.3.5

• Get GNU commands on windows (not necessary)– Install git (MINGW)– Install Cygwin (too fat)

Installation

Page 7: Vagrant

04/11/2023 Copyright 2013 Trend Micro Inc.

ArchitectureProviders

Page 8: Vagrant

04/11/2023 Copyright 2013 Trend Micro Inc.

• Via VBoxManage tool

• list running VM– $ VBoxManage list runningvms

• pause VM– $ VBoxManage controlvm <vmname> pause

• send poweroff single to VM (tells VM OS to shutdown)– $ VBoxManage controlvm <vmname> acpipowerbutton

• …

How does it work?

Page 9: Vagrant

04/11/2023 Copyright 2013 Trend Micro Inc.

• Deploy a project on a machine for testing– mess things up– Fix it – …loop…

• Environment specific– I can run it well on MY machine

(cause I only test it on my machine)

• Can not automate

• I don’t have machines…

Why we need it

Page 10: Vagrant

04/11/2023 Copyright 2013 Trend Micro Inc.

Problem to solve

• Provisioning: – automate trivial things

• install httpd, mysql, config, config, config…

• reuse:– Package configured VM as a “box”

• testing:– clean environment for testing

• Portable:– one box file– local machine

Page 11: Vagrant

04/11/2023 Copyright 2013 Trend Micro Inc.

Create VM

Page 12: Vagrant

04/11/2023 Copyright 2013 Trend Micro Inc.

• Vm status control:– Up– halt– destroy– reload

(for config change)– resume– suspend

Basic Commands

Page 13: Vagrant

04/11/2023 Copyright 2013 Trend Micro Inc.

• vagrant box add precise32 http://files.vagrantup.com/precise32.box

• Vagrant init precise32 (new a vagrantfile)

• Vagrant up (create VM)

• vagrant ssh (get into the VM)

Create a VM

Page 14: Vagrant

04/11/2023 Copyright 2013 Trend Micro Inc.

• default : eth0 for NAT

• Port forwarding– config.vm.network :forwarded_port, host: 8070, guest: 8070

• Host-only– config.vm.network :private_network, ip: "192.168.56.2“

• Bridge– config.vm.network :public_network– config.vm.network :public_network, :bridge => 'en0: Wi-Fi

(AirPort)‘• (Not always work)

Networking

Page 15: Vagrant

04/11/2023 Copyright 2013 Trend Micro Inc.

• Hardware spec.– config.vm.provider :virtualbox do |vb|– vb.customize ["modifyvm", :id, "--memory", "1024"]– end

• Hostname– config.vm.hostname = “YOUR_HOSTNAME“

• Share folder– config.vm.synced_folder "../data", "/vagrant_data“ host guest

More settings in Vagrantfile

Page 16: Vagrant

04/11/2023 Copyright 2013 Trend Micro Inc.

Provisioning

Page 17: Vagrant

04/11/2023 Copyright 2013 Trend Micro Inc.

• Auto execute the shell script as root

• Vagrantfile syntax:– config.vm.provision :shell, :path => "bootstrap.sh"

• Command– $ vagrant provision –provision-with shell

Shell

Page 18: Vagrant

04/11/2023 Copyright 2013 Trend Micro Inc.

• Auto apply a puppet script

• Vagrantfile syntax:– config.vm.provision :puppet do |puppet|– puppet.manifests_path = "manifests"– puppet.manifest_file = "init.pp"– end

• Folder structure:– Vagrantfile– Manifests

– Init.pp

Puppet

Page 19: Vagrant

04/11/2023 Copyright 2013 Trend Micro Inc.

• vagrant plugin install vagrant-vbox-snapshot

• vagrant plugin install vagrant-vbguest

Plugins

Page 20: Vagrant

04/11/2023 Copyright 2013 Trend Micro Inc.

Q&A

Page 21: Vagrant

04/11/2023 Copyright 2013 Trend Micro Inc.

Backup Slides

Page 22: Vagrant

04/11/2023 Copyright 2013 Trend Micro Inc.

• ssh– Install git (MINGW)– Install Cygwin (too fat, I think)

• There’re many ways you can do to achieve this goal,My suggestion is to install git on your windows– Download git– 6 page quick tutorial

• Then use putty to ssh in.

Get ssh command on windows


Recommended