Vagrant + Packer + AWS + Virtual box: The box you attempted to add doesn't match the provider you specified.

404 views
Skip to first unread message

Miguel David

unread,
Oct 15, 2016, 4:09:16ā€ÆPM10/15/16
to Vagrant
Hi,

Firstly apologies if this came up already. I was not able to find it with Google searches.
This is a packer-vagrant mixed issue, so I know that it could be also in packer's group.

What I am trying to do is to use packer to create an AWS instance, provision it (with ansible), generate an AWS AMI and postprocessing would generate a vagrant box.
The whole process runs smoothly, but when I try to vagrant up that box I get "The box you attempted to add doesn't match the provider you specified.".

Here is the relevant code from packer's json:

{
Ā  "variables": {
Ā  Ā  ...
Ā  },
Ā  "builders": [
Ā  Ā  {
Ā  Ā  Ā  "type": "amazon-ebs",
Ā  Ā  Ā  "access_key": "{{user `aws_access_key`}}",
Ā  Ā  Ā  "secret_key": "{{user `aws_secret_key`}}",
Ā  Ā  Ā  "region": "{{user `region`}}",
Ā  Ā  Ā  "source_ami": "{{user `source_ami`}}",
Ā  Ā  Ā  "instance_type": "{{user `size`}}",
Ā  Ā  Ā  "ssh_username": "{{user `user`}}",
Ā  Ā  Ā  "ami_name": "{{user `temp_box`}}",
Ā  Ā  Ā  "ami_description": "{{user `ami_desc`}}",
Ā  Ā  Ā  "ami_regions": [
Ā  Ā  Ā  Ā  "eu-west-1",
Ā  Ā  Ā  Ā  "eu-central-1"
Ā  Ā  Ā  ],
Ā  Ā  Ā  "associate_public_ip_address": true,
Ā  Ā  Ā  "force_deregister": true,
Ā  Ā  Ā  "run_tags": {
Ā  Ā  Ā  Ā  "type": "packertempinstance"
Ā  Ā  Ā  },
Ā  Ā  Ā  "tags": {
Ā  Ā  Ā  Ā  "type": "packerimage",
Ā  Ā  Ā  Ā  "tag2": "stuff"
Ā  Ā  Ā  },
Ā  Ā  Ā  "temporary_key_pair_name": "{{user `tmp_keypair`}}"
Ā  Ā  }
Ā  ],
Ā  "provisioners": [
Ā  Ā  {
Ā  Ā  Ā  "type": "shell",
Ā  Ā  Ā  "inline": [
Ā  Ā  Ā  Ā  "while [ ! -f /var/lib/cloud/instance/boot-finished ]; do echo 'Waiting for cloud-init...'; sleep 1; done"
Ā  Ā  Ā  ]
Ā  Ā  },
Ā  Ā  {
Ā  Ā  Ā  "type": "shell",
Ā  Ā  Ā  "execute_command": "echo 'packer' | {{.Vars}} sudo -S -E bash '{{.Path}}'",
Ā  Ā  Ā  "inline": ["apt install python-minimal aptitude -y"]
Ā  Ā  },
Ā  Ā  {
Ā  Ā  Ā  "type": "ansible",
Ā  Ā  Ā  "playbook_file": "./playbook.yml",
Ā  Ā  Ā  "groups": ["all", "app"],
Ā  Ā  Ā  "ssh_host_key_file": "/Users/myuser/.ssh/mykey.pem",
Ā  Ā  Ā  "extra_arguments": "-v",
Ā  Ā  Ā  "ansible_env_vars": [ "ANSIBLE_HOST_KEY_CHECKING=False" ]
Ā  Ā  },
Ā  Ā  {
Ā  Ā  Ā  "type": "shell",
Ā  Ā  Ā  "execute_command": "echo 'packer' | {{.Vars}} sudo -S -E bash '{{.Path}}'",
Ā  Ā  Ā  "script": "cleanup.sh"
Ā  Ā  }
Ā  ],
Ā  "post-processors": [
Ā  Ā  {
Ā  Ā  Ā  "type": "vagrant",
Ā  Ā  Ā  "keep_input_artifact": true,
Ā  Ā  Ā  "output": "modified-xenial.box"
Ā  Ā  }
Ā  ]
}

When the modified-xenial.box is generated I'm adding it as a box:
# vagrant box add mybox `pwd`/modified-xenial.box
And then:
# vagrant init mybox -m

At this point I have a Vagrantfile like this:

$ cat Vagrantfile
Vagrant.configure("2") do |config|
Ā  config.vm.box = "mybox"
Ā  config.vm.box_url = ["file:///Users/myuser/Dev/modified-xenial.box"]
end

However, when I vagrant up it I get this:

$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Box 'mybox' could not be found. Attempting to find and install...
Ā  Ā  default: Box Provider: virtualbox
Ā  Ā  default: Box Version: >= 0
==> default: Box file was not detected as metadata. Adding it directly...
==> default: Adding box 'mybox' (v0) for provider: virtualbox
Ā  Ā  default: Unpacking necessary files from: file:///Users/myuser/Dev/modified-xenial.box
The box you attempted to add doesn't match the provider you specified.

Provider expected: virtualbox
Provider of box: aws

I understand that the original box was built using AWS's builder from packer, but the postprocessor should generate a vagrant/Virtualbox friendly box, right?

Any help into what I am doing wrong is appreciated.

Cheers,
Miguel

Alvaro Miranda Aguilera

unread,
Oct 15, 2016, 4:18:40ā€ÆPM10/15/16
to vagra...@googlegroups.com
hello

by default Vagrant up witll try virtualbox.

as you can see here:

Provider expected: virtualbox
Provider of box: aws

try:
vagrant up --provider aws

and make sure you have the aws plugin

vagrant plugin list
vagrant plugin install vagrant-aws

Thanks
Alvaro.

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
Ā 
GitHub Issues: https://github.com/mitchellh/vagrant/issues
IRC: #vagrant on Freenode
---
You received this message because you are subscribed to the Google Groups "Vagrant" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vagrant-up+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vagrant-up/2b502110-c2b5-43a5-8833-32b58d8af338%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Alvaro

Miguel David

unread,
Oct 15, 2016, 5:56:25ā€ÆPM10/15/16
to vagra...@googlegroups.com, Alvaro Miranda Aguilera
Hi Alvaro,

Thanks for replying.Ā 

When I do "vagrant up --provider=awsā€ it tries to create a VM on Amazonā€™s servers (as expected).
$ vagrant up --provider=aws
Bringing machine 'default' up with 'aws' provider...
==> default: Warning! The AWS provider doesn't support any of the Vagrant
==> default: high-level network configurations (`config.vm.network`). They
==> default: will be silently ignored.
==> default: Warning! You didn't specify a keypair to launch your instance with.
==> default: This can sometimes result in not being able to access your instance.
==> default: Launching an instance with the following settings...
==> default: Ā -- Type: m3.medium
==> default: Ā -- AMI: ami-5b49b734
==> default: Ā -- Region: eu-central-1
==> default: Ā -- Block Device Mapping: []
==> default: Ā -- Terminate On Shutdown: false
==> default: Ā -- Monitoring: false
==> default: Ā -- EBS optimized: false
==> default: Ā -- Source Destination check:
==> default: Ā -- Assigning a public IP address in a VPC: false
==> default: Ā -- VPC tenancy specification: default
There was an error talking to AWS. The error message is shown...

What I am trying to do is to vagrant up a local virtual machine besides the AWS AMI, not an EC2 instance.

I hope this clears up my goal here. Help?

--
Miguel
WebsiteĀ -Ā LinkedInĀ -Ā Taste Porto

To unsubscribe from this group and stop receiving emails from it, send an email to vagrant-up+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vagrant-up/CAHqq0exY3vGwj%3DYuW5DOnj09yBfZPQtkFxkq-BDYdzKj%3DG_mTA%40mail.gmail.com.

Selenium Framework

unread,
Dec 3, 2016, 9:57:01ā€ÆPM12/3/16
to Vagrant, migue...@gmail.com
Hi,
I am running into same issue and my expectation is to be able to launch a virtualbox instance from the .box file that got created (because I had a post processor step in packer file).Ā 
If an aws ec2 instance is being created , then why would I need to create a "vagrant/virtualbox" post processor in first place. I already have the ami created right ? Below is my packer template.

Enter code here...{
Ā  "variables": {
Ā  Ā  "aws_access_key": "",
Ā  Ā  "aws_secret_key": ""
Ā  },
Ā  "builders": [{
Ā  Ā  "type": "amazon-ebs",
Ā  Ā  "access_key": "{{user `aws_access_key`}}",
Ā  Ā  "secret_key": "{{user `aws_secret_key`}}",
Ā  Ā  "region": "us-east-1",
Ā  Ā  "source_ami": "ami-fce3c696",
Ā  Ā  "instance_type": "t2.micro",
Ā  Ā  "ssh_username": "ubuntu",
Ā  Ā  "ami_name": "packer-example {{timestamp}}"
Ā  }],
Ā  "provisioners": [{
Ā  Ā  "type": "shell",
Ā  Ā  "inline": [
Ā  Ā  Ā  "sleep 30",
Ā  Ā  Ā  "sudo apt-get update",
Ā  Ā  Ā  "sudo apt-get install -y redis-server"
Ā  Ā  ]
Ā  }],
Ā  "post-processors": ["vagrant"]
}



Reply all
Reply to author
Forward
0 new messages