Skip to content

Instantly share code, notes, and snippets.

@ederrafo
Last active February 26, 2020 19:31
Show Gist options
  • Save ederrafo/8117e02bd25a4fd6fc5e751a133bcd69 to your computer and use it in GitHub Desktop.
Save ederrafo/8117e02bd25a4fd6fc5e751a133bcd69 to your computer and use it in GitHub Desktop.
devops vagrant virtual machine vm

Listar todos las VM

 $ vagrant global-status
 $ vagrant box list

Discover vagrant boxes

https://app.vagrantup.com/boxes/search?utf8=%E2%9C%93&sort=downloads&provider=&q=

Boxes disponibles

http://www.vagrantbox.es/

Descarga un Box:

$ wget https://cloud-images.ubuntu.com/vagrant/trusty/current/trusty-server-cloudimg-amd64-vagrant-disk1.box

Para crear una VM creamos el directorio

$ vagrant init

Or with title

$ vagrant init {title}

Añade el Box descargado a Vagrant: vagrant box add {title} {url}

 $ vagrant box add trusty-64 trusty-server-cloudimg-amd64-vagrant-disk1.box

Init the virtual machine

$ vagrant up

Create Ubuntu 16 virtual machine

First we will create the folder, and then

$ vagrant init ubuntu/xenial64
$ vagrant up

En el archivo Vagrantfile descomentamos estas lineas:

config.vm.box = "trusty-64" # colocamos el nombre del box
config.vm.network "private_network", ip: "192.168.33.11"

Now, going to configure Vagrantfile file

#default
config.vm.synced_folder "../../Data", "/var/www/html/", :group => 'www-data'
# Ubuntu host
config.vm.synced_folder "projects", "/var/www/"
# Windows host
config.vm.synced_folder "D:\/eder\/projects", "/var/www/html/", :group => "www-data"

Iniciar la VM

Command: vagrant up [name|id]

  $ vagrant up
  $ cd /path/to/vagrant_vm1 && vagrant up

LogIn in VM

Command: vagrant ssh [name|id]

$ vagrant ssh 
$ vagrant ssh d205993
$ ssh [email protected]

To print or view the current VirtualBox version you should use below command:

$ vboxmanage --version

or

$ echo $(vboxmanage --version )

Remove box

command: vagrant remove <name|id>

 $ vagrant box remove f60b727c80424e088409a8bdbcc89685
 $ vagrant box remove trusty

Box update/destroy

vagrant update [name|id]

 $ vagrant box update d205993

vagrant destroy [name|id]

$ vagrant destroy f60b727c80424e088409a8bdbcc89685

Possible errors

WARNING: The character device /dev/vboxdrv does not exist.
Please install the virtualbox-dkms package and the appropriate
headers, most likely linux-headers-generic.
You will not be able to start VMs until this problem is fixed.
4.3.10_Ubuntur9301

Solution: solve it by disabling secure boot (via BIOS).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment