I have created my Vagrantfile below
Vagrant.configure("2") do |config|
config.vm.box = "bento/ubuntu-18.04"
config.vm.network "forwarded_port", guest: 8080, host: 8080
config.vm.network "forwarded_port", guest: 5901, host: 5901
config.vm.provider "virtualbox" do |vb|
# Display the VirtualBox GUI when booting the machine
vb.gui = false
# Customize the amount of memory on the VM:
vb.memory = "2560"
end
end
I want to use this Vagrantfile for created box.
My packer template JSON file is below
packer_template.json
{
"builders": [
{
"communicator": "ssh",
"source_path": "bento/ubuntu-18.04",
"provider": "virtualbox",
"type": "vagrant",
"output_vagrantfile": "Vagrantfile"
}
],
"provisioners": [
{
"type": "shell",
"script": "packer_script.sh"
},
{
"type": "ansible-local",
"playbook_file": "site.yml",
"playbook_dir": "."
}
]
}
Run packer build packer_template.json
. This result is created output-vagrant directory.
This directory included Vagrantfile below
Vagrant.configure("2") do |config|
config.vm.define "source", autostart: false do |source|
source.vm.box = "bento/ubuntu-18.04"
config.ssh.insert_key = false
end
config.vm.define "output" do |output|
output.vm.box = "packer_vagrant"
output.vm.box_url = "file://package.box"
config.ssh.insert_key = false
end
config.vm.synced_folder ".", "/vagrant", disabled: true
end
So, executing vagrant up
is launch output
VM.
Then vagrant ssh
result is This command requires a specific VM name to target in a multi-VM environment.
.
I’m using Packer v1.6.0.
Question:
- I want to
vagrant up
->vagrant ssh
without specify VM name. - I want to use my Vagrantfile instead of the defined
source
andoutput
VM.
How to?
Am I wrong?
Thanks.