cmdref.net - Command Reference

This site is command references for system engineers.

User Tools

Site Tools


Top     SiteMap

Sidebar

Top     SiteMap








Etc


Reference











.

software:vargant:index.html



Middleware

Vargant

Introduction

What is Vargant

Vagrant is a tool for building complete development environments.


Where do you search Box Files?

Atlas

URLBox URL
http://atlas.hashicorp.com/XXXXXXX/ http://atlas.hashicorp.com/XXXXXXX/versionx.x.x/providers/virtualbox.box
https://atlas.hashicorp.com/bento/boxes/centos-7.2 https://atlas.hashicorp.com/bento/boxes/centos-7.2/versions/2.2.9/providers/virtualbox.box

Vagrantbox.es

Install

Windows

  1. Install VirtualBox https://www.virtualbox.org/


Commands

Box Commands

vagrant box add BOXNAME BOXFILE Download a Box File to local host
vagrant box remove BOXFILE delete box file
vagrant box list List BOX
vagrant init box Create Vagrantfile
vagrant package
vagrant package --base NAME
Create Box Files. (package.box)
vagrant box add IMPORT-NAME package.box
vagrant box add CentOS-6.6-minimal-ja package.box
Import box a file

VM Commands

vagrant up start VM from Vagrantfile
vagrant reload restart VM
vagrant status List VM with start
vagrant global-status List all VM status
vagrant halt stop VM
vagrant destroy delete VM initialized state
vagrant ssh login with ssh (If you using Linux or Mac OS)


How to use vagrant

Download boxs

# vagrant box add centos-5.10 https://dl.dropboxusercontent.com/s/r5okkx8330h3tzh/vagrant-centos-5.10-x86_64.box
# vagrant box list

For Windows, downloaded C:\Users\user01\.vagrant.d\boxes\ directory.

Start Up VM

# mkdir test
# cd test
# vagrant init centos-5.10

Edit Vagrantfile

# vagrant up

# vagrant status
  • root password is 'vagrant'.
  • vagrant user's password is 'vagrant'.
  • Copy VMDK files to C:\Users\user01\VirtualBox VMs\

Holt VM

# vagrant status

# vagrant halt

# vagrant status

Delete VM

# vagrant destroy

Delete Boxs

# vagrant box remove


Configuration of Vagrantfile

Vagrant.configure("2") do |config|
  config.vm.box = "chef/centos-7.2"

  #Bridged network DHCP
  config.vm.network "private_network"

  # share configuraiton with PC and VM
  # Host's sysnc_folder and VM's /home/vagrant/sync_folder
  config.vm.synced_folder "./data", "/vagrant_data", type: "nfs"

  config.vm.provider "virtualbox" do |v|
    v.memory = 512
    v.customize ["modifyvm", :id, "--cpus", "1"]
  end

end
  config.vm.provider "virtualbox" do |v|
    v.memory = 1024
    v.customize ["modifyvm", :id, "--cpus", "2"]
  end
  # Create a forwarded port mapping which allows access to a specific port
  # within the machine from a port on the host machine. In the example below,
  # accessing "localhost:8080" will access port 80 on the guest machine.
  config.vm.network "forwarded_port", guest: 80, host: 8080
  config.vm.network "forwarded_port", guest: 22, host: 10022
  # Share an additional folder to the guest VM. The first argument is
  # the path on the host to the actual folder. The second argument is
  # the path on the guest to mount the folder. And the optional third
  # argument is a set of non-required options.
   config.vm.synced_folder "./data", "/vagrant_data"


MULTI-MACHINE

Vagrant.configure("2") do |config|
  config.vm.provision "shell", inline: "echo Hello"

  config.vm.define "web" do |web|
    web.vm.box = "apache"
  end

  config.vm.define "db" do |db|
    db.vm.box = "mysql"
  end
end
Vagrant.configure(2) do |config|

  config.vm.box = "xxxxx"

  config.vm.define :test1 do |cfg|
    cfg.vm.hostname = "test1"
    cfg.vm.network "private_network", ip: "192.168.10.11", virtualbox__intnet: "intnet"
  end

  config.vm.define :test2 do |cfg|
    cfg.vm.hostname = "test2"
    cfg.vm.network "private_network", ip: "192.168.10.12", virtualbox__intnet: "intnet"
  end

end


Troubleshooting

Authentication failure. Retrying...

# vargrant up

    default: Warning: Authentication failure. Retrying...

Check Permission

/home/vagrant    700 or 755 or 711
/home/vagrant/ssh    700
/home/vagrant/ssh/authorized_keys  600    



software/vargant/index.html.txt ยท Last modified: 2017/06/20 by admin