How start a local VM built by packer? - vagrant

I am new to packer.
For a start I tried to build: https://github.com/shiguredo/packer-templates/tree/develop/ubuntu-14.04 which worked fine. But when I want to sin it up via vagrant up I get the following error:
Vagrant environment or target machine is required to run this
command. Run `vagrant init` to create a new Vagrant environment. Or,
get an ID of a target machine from `vagrant global-status` to run
this command on. A final option is to change to a directory with a
Vagrantfile and to try again.
After calling vagrant init a config file which looks like a default config file is created. But still there are errors:
Bringing machine 'default' up with 'parallels' provider...
==> default: Box 'base' could not be found. Attempting to find and install...
default: Box Provider: parallels
default: Box Version: >= 0
==> default: Adding box 'base' (v0) for provider: parallels
default: Downloading: base
An error occurred while downloading the remote file. The error
message, if any, is reproduced below. Please fix this error and try
again.
Couldn't open file /Downloads/packer-templates-develop/ubuntu-14.04/base
How can I start my packer-generated VM locally?
Is the only solution to keep track of the Vagrantfile manually?
Edit:
if I call vagrant init myNewlyCreatedBox.box
Then vagrant will try too boot the VM but
Failed to mount folders in Linux guest. This is usually because
the "prl_fs" file system is not available. Please verify that
Parallels Tools are properly installed in the guest and
can work properly. If so, the VM reboot can solve a problem.
The command attempted was:
mount -t prl_fs -o uid=`id -u vagrant`,gid=`getent group vagrant | cut -d: -f3` vagrant /vagrant
mount -t prl_fs -o uid=`id -u vagrant`,gid=`id -g vagrant` vagrant /vagrant

Those templates will generate a Vagrant box for you. If the process completes successfully you should have ubuntu-14-04-x64-virtualbox.box and ubuntu-14-04-x64-vmware.box file as specified by template.json file. To use those newly created boxes in Vagrant you'll need to add the one corresponding to your specific hypervisor to the list of boxes that Vagrant knows about by the following:
vagrant box add <nameToReferToBox> <pathToBoxYouJustCreated>
for example
vagrant box add ubuntu-14-04-x64 ubuntu-14-04-x64-virtualbox.box
Then to create an instance of that box (a VM) you can simply create a Vagrant file targeting the new box you just imported:
vagrant init ubuntu-14-04-x64
and then spin up a VM based on the base box:
vagrant up

Related

Issues w vagrant ssh: terminating, 1 bad configuration options

first off I'm very new to programming and web development. I'm currently working through a Udacity course on SQL.
I'm trying to install VM and Vagrant and have run into this issue. Vagrant installed fine, and I'm able to run vagrant up, but when I run vagrant ssh I'm getting this message:
.ssh/config: terminating, 1 bad configuration options
I'll attach a screen here.
I'm on a Mac. Big Sur 11.5.2
Vagrant version 2.2.18
Any help provided would be greatly appreciated! Thanks in advance![enter image description here][1]
bash-3.2$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Checking if box 'bento/ubuntu-16.04-i386' version '2.3.5' is up to date...
==> default: Machine already provisioned. Run vagrant provision or use the --provision
==> default: flag to force provisioning. Provisioners marked to run always will still run.
bash-3.2$ vagrant ssh
/Users/scott27/.ssh/config: terminating, 1 bad configuration options
bash-3.2$
Consider moving your config file to a backup and trying again.
mv /Users/scott27/.ssh/config /Users/scott27/.ssh/config.bak
Then try vagrant up again and if it works then the issue is in your config file, troubleshoot that separately.
Instead of moving the existing ssh config file it is better to instead let vagrant point to its own config file using the config.ssh.config in vagrantfile
I am on Windows but I assume it is similar on mac. I updated my Vagrantfile like so:
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.ssh.config = File.expand_path(File.dirname(__FILE__) + '/ssh_config')
As you can see I point to a ssh_config file that I created, since an empty string resulted in an error.

Vagrant: "The box you're attempting to add already exists"

I am pretty new to Vagrant and already I seem to have hit a snag with it. I am basically following their get started guide.
When I type the command:
$ vagrant box add hashicorp/precise64
I get this error:
The box you're attempting to add already exists. Remove it before
adding it again or add it with the --force flag.
Name: hashicorp/precise64
Provider: virtualbox
Version: 1.1.0
Here is what I have tried.
I destroyed it first using:
$ vagrant destroy
I then backed out into documents using:
$ cd -
I then removed the director with:
$ rm -rf vagrant_getting_started
Then I created a new directory with:
$ mkdir vagrant_getting_started
I then went into that directory with:
$ cd vagrant_getting_started
Then I typed:
$ vagrant box add hashicorp/precise64
Which gave me:
==> box: Loading metadata for box 'hashicorp/precise64'
box: URL: https://vagrantcloud.com/hashicorp/precise64
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) virtualbox
3) vmware_fusion
Enter your choice:
Finally I chose option 2 and then this is where the error is.
Can anyone see anything that I am doing wrong?
vagrant box remove -f laravel/homestead will remove the "laravel/homestead" from your machine and you can reinstall the same by vagrant box add laravel/homestead.
Unless the Vagrant box image has become corrupted, you don't need to download it again to re-use it.
Vagrant only downloads the boxes it doesn't have. Once a box image is saved locally on your system, Vagrant will use the local image to work from.
When setting up a new Vagrant based project, the following will happen:
You create or navigate to your project directory
Run vagrant init hashicorp/precise64. This will initialise Vagrant inside the directory, and create a new Vagrantfile if one doesn't exist. It also tells Vagrant which box image to use. If the box image is already stored locally - it won't download it.
Alternatively, if you already have a Vagrantfile in your project directory, simply run vagrant up. Vagrant will take care of everything for you - including downloading the box image (if applicable).

Homestead up conflicts with the VM it created

I am progressively updating files to get rid of errors to get laravel setup.
I am now running into this error when i run homestead up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'laravel/homestead'...
←[K==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'laravel/homestead' is up to date...
A VirtualBox machine with the name 'homestead' already exists.
Please use another name or delete the machine with the existing
name, and try again.
I opened Virtualbox but couldnt find any VM's so after some research I ran vagrant golbal-status and destroyed any VM's with vagrant destroy <VM id>
This didnt seem to work so I manually deleted the .vagrant folder from the Homestead directory and retried.
After the error, when I run vagrant global-status again it shows the VM that is created, so its as if homestead creates the machine and then tried to recreate it? hence the conflict. This is the second day of trying to get laravel going, im on windows 8.1 T^T
i had the same issue.The following fixed it for me.
from the terminal run the command
$vagrant global-status
the output was
id name provider state directory
74c92a7 default virtualbox poweroff /home/maiko/.composer/vendor/laravel/homestead
e73c724 default virtualbox poweroff /home/maiko/Desktop/code/Homestead
what i did was delete the hometead instance of 74c92a7
$vagrant destroy 74c92a7
once i ran vagrant up again everything went smooth.
hope that helps

Vagrant, error when running vagrant up --provider=docker

I'm trying to test the new docker support in vagrant 1.6. I'm on windows and I've setup my vagrant file but when I run "vagrant up --provider=docker" I get the following:
Bringing machine 'default' up with 'docker' provider...
==> default: Docker host is required. One will be created if necessary...
default: Vagrant will now create or start a local VM to act as the Docker
default: host. You'll see the output of the `vagrant up` for this VM below.
default:
default: Box 'mitchellh/boot2docker' could not be found. Attempting to find and install...
default: Box Provider: virtualbox
default: Box Version: >= 0
default: Loading metadata for box 'mitchellh/boot2docker'
default: URL: https://vagrantcloud.com/mitchellh/boot2docker
default: Adding box 'mitchellh/boot2docker' (v0.8.0) for provider: virtualbox
default: Downloading: https://vagrantcloud.com/mitchellh/boot2docker/version/1/provider/virtualbox.box
default: Progress: 100% (Rate: 2999k/s, Estimated time remaining: --:--:--)
The executable 'bsdtar' Vagrant is trying to run was not
found in the %PATH% variable. This is an error. Please verify
this software is installed and on the path.
Uninstall Vagrant completely, remove C:\HashiCorp.
Reinstall Vagrant.
This will fix everything.
Go to Programs and Features
Find Vagrant and Repair
No need to reinstall :)
a fast solution is to attach the path of the mingw binary location to the system's Path variable, e.g.:
C:\HashiCorp\Vagrant\embedded\mingw\bin
Remember to separate path entries with a ;.
Download & Install package follow instruction here http://gnuwin32.sourceforge.net/packages/libarchive.htm
then update your Path environment variable to include the installed path of bsd executable, usually C:\Program Files (x86)\GnuWin32\bin

vagrant can't find existing box

i was add box with local file from https://dl.dropboxusercontent.com/s/x1085661891dhkz/lxc-centos6.5-2013-12-02.box
vagrant box add centos centos.box
vagrant init centos
my shell:
cheneytekimbp:vagrant-centos zicjin$ vagrant box list
centos (lxc, 0)
lucid32 (virtualbox, 0)
cheneytekimbp:vagrant-centos zicjin$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Box 'centos' could not be found. Attempting to find and install...
default: Box Provider: virtualbox
default: Box Version: >= 0
==> default: Adding box 'centos' (v0) for provider: virtualbox
default: Downloading: centos
An error occurred while downloading the remote file. The error
message, if any, is reproduced below. Please fix this error and try
again.
Couldn't open file /Users/zicjin/Work/vagrant-centos/centos
Add the local box file using the full path with the file protocol URI. For instance:
vagrant box add centos file:///Users/zicjin/Work/vagrant-centos/centos.box
(the exact location of course depends on where you've put the file)
$ vagrant box add CentOSMinimal https://dl.dropbox.com/u/7225008/Vagrant/CentOS-6.3-x86_64-minimal.box
$ vagrant init CentOSMinimal
$ vagrant up
If you're on windows, you can define the path as:
vagrant box add box_name "C:\Users\JohnDoe\blahblah\box_name.box"
Notice the .box at the end of the path.
Then you can cd into the directory if you're not already there and do vagrant up.
I've solved a similar issue upgrading Vagrant to the latest version and magically it works... :/

Resources