Skip to content

Basic scenarios on managing virtual machines with Vagrant

License

Notifications You must be signed in to change notification settings

SideMasterGM/Vagrant

 
 

Repository files navigation

Vagrant practices

Basic scenarios on managing virtual machines with Vagrant.


Vagrantfile file generated by default

Initialize the virtual machine with the box: debian/jessie64 to VirtualBox.

Initial instruction

vagrant init -m debian/jessie64

Vagrantfile generated

Vagrant.configure("2") do |config|
    config.vm.box = "debian/jessie64"
end

Basic configurations

Hostname

config.vm.hostname = "jerson-martinez"

For more details, go here: Initial-Debian/

Choosing provider

config.vm.provider "virtualbox" do | vb |
    #Configurations
end

Assign name, memory and cpus

vb.name = "HereWriteTheName"
vb.memory = "512"
vb.cpus = "2"

For more details, go here: ConfigProvidersOnVirtualBox/

Passing the command instructions to the virtual machine

config.vm.provision :shell, inline: "sudo apt-get update && sudo apt-get -y install apache2"

Apply linked clone

vb.linked_clone = true

For more details, go here: LinkedClone/

Forwarded Port (80:8080)

config.vm.network "forwarded_port", guest: 80, host: 8080

For more details, go here: ForwardedPort/

Configure disks

firt_disk   = 'tmp/disk.vdi'
controller  = "SATA Controller"
device      = 0
type        = "hdd"

unless File.exist?(firt_disk)
    vb.customize ['createhd', 
            '--filename',   firt_disk, 
            '--size',       300 * 1024]
end

vb.customize ['storageattach', :id, 
            '--storagectl',      "#{controller}", 
            '--port',            1, 
            '--device',          "#{device}", 
            '--type',            "#{type}", 
            '--medium',          firt_disk]

For more details, go here: ConfigDisk/

Start the image

vagrant up

Install Plugins

RSync Back Bidirectional rsync

vagrant plugin install vagrant-rsync-back

Mode use:

vagrant rsync-back

About

Basic scenarios on managing virtual machines with Vagrant

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • PHP 61.5%
  • JavaScript 24.3%
  • CSS 11.5%
  • HTML 2.4%
  • Other 0.3%