I have a vagrantfile using a box on top of virtualbox with a provision script.
Now I am trying to use packer to output a box already after provision.
However I cannot find a builder to use the ".box" file I already have. What am I doing wrong?
I just got a solution to this tiny little problem (convert a vagrant .box file to .ova for use by packer):
Vagrantfile
, with box opscode-centos-7.0
:$provisioning_script = <<PROVISIONING_SCRIPT adduser packer echo "packer" | passwd packer --stdin echo "packer ALL=(ALL:ALL) NOPASSWD: ALL" > /etc/sudoers.d/packer PROVISIONING_SCRIPT Vagrant.configure(2) do |config| config.vm.box = "opscode-centos-7.0" config.ssh.insert_key = false config.vm.provider "virtualbox" do |v| v.name = "packer-base" end config.vm.provision :shell, inline: $provisioning_script end
vagrant up
vagrant halt
vboxmanage export --ovf20 -o packer-base.ova packer-base
vagrant destroy
This also creates the packer
user with a default password so that packer can easily connect to the instance to do stuff. Also note the insert_key
parameter that will prevent replacing the vagrant default insecure key with a secure one and allow subsequent vagrant setups to properly connect via SSH to the new images (after packer is done).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With