The installation of a box is also easily done. There are couple tasks which we have to do before that:
- Create a new folder
- From that folder download the box
- Install the box
Let's start going:
Basic Box Configuration
PS C:\Users\Julien> cd F: PS F:\> mkdir E:\Virtuals\Ainsible PS F:\> cd E:\Virtuals\Ainsible PS E:\Virtuals\Ainsible> dir
Download + Install the Box
The box will be downloaded from the official site: https://app.vagrantup.com/boxes/search
Also, you can check the link for the box from the download configuration file:
Vagrant.configure("2") do |config| config.vm.box = "centos/7" <- Link config.vm.box_version = "1804.02" end
PS E:\Virtuals\Ainsible> vagrant box add centos/7 ==> box: Loading metadata for box 'centos/7' box: URL: https://vagrantcloud.com/centos/7 This box can work with multiple providers! The providers that it can work with are listed below. Please review the list and choose the provider you will be working with. 1) hyperv 2) libvirt 3) virtualbox 4) vmware_desktop Enter your choice: 3 ==> box: Adding box 'centos/7' (v1804.02) for provider: virtualbox box: Downloading: https://vagrantcloud.com/centos/boxes/7/versions/1804.02/providers/virtualbox.box box: Download redirected to host: cloud.centos.org box: Progress: 100% (Rate: 437k/s, Estimated time remaining: --:--:--) ==> box: Successfully added box 'centos/7' (v1804.02) for 'virtualbox'!
Start the box
After the box have been downloaded, we are free to initialize it and import it as follows:
PS E:\Virtuals\Ainsible> vagrant init centos/7 A `Vagrantfile` has been placed in this directory. You are now ready to `vagrant up` your first virtual environment! Please read the comments in the Vagrantfile as well as documentation on `vagrantup.com` for more information on using Vagrant. E:\Virtuals\Ainsible>vagrant up Bringing machine 'default' up with 'virtualbox' provider... ==> default: Importing base box 'centos/7'... ==> default: Matching MAC address for NAT networking... ==> default: Checking if box 'centos/7' is up to date... ==> default: Setting the name of the VM: Ainsible_default_1534168275677_88434 ==> default: Clearing any previously set network interfaces... ==> default: Preparing network interfaces based on configuration... default: Adapter 1: nat ==> default: Forwarding ports... default: 22 (guest) => 2222 (host) (adapter 1) ==> default: Booting VM... ==> default: Waiting for machine to boot. This may take a few minutes... default: SSH address: 127.0.0.1:2222 default: SSH username: vagrant default: SSH auth method: private key default: default: Vagrant insecure key detected. Vagrant will automatically replace default: this with a newly generated keypair for better security. default: default: Inserting generated public key within guest... default: Removing insecure key from the guest if it's present... default: Key inserted! Disconnecting and reconnecting using new SSH key... ==> default: Machine booted and ready! ==> default: Checking for guest additions in VM... default: No guest additions were detected on the base box for this VM! Guest default: additions are required for forwarded ports, shared folders, host only default: networking, and more. If SSH fails on this machine, please install default: the guest additions and repackage the box to continue. default: default: This is not an error message; everything may continue to work properly, default: in which case you may ignore this message. ==> default: Rsyncing folder: /cygdrive/e/Virtuals/Ainsible/ => /vagrant
Install Guest Plugin
In order to install the guest plugin, you have to run it from the folder of the box:
E:\Virtuals\Ainsible>vagrant plugin install vagrant-vbguest Installing the 'vagrant-vbguest' plugin. This can take a few minutes... Fetching: micromachine-2.0.0.gem (100%) Fetching: vagrant-vbguest-0.15.2.gem (100%) Installed the plugin 'vagrant-vbguest (0.15.2)'! E:\Virtuals\Ainsible>