vagrant icon indicating copy to clipboard operation
vagrant copied to clipboard

Publish vagrant cloud from local box

Open spgyip opened this issue 4 years ago • 2 comments

Predefination: local box: box in vagrant local repository local box file: local box file dump with vagrant package|repackage cloud box: box in vagrant cloud

It seems that there is no way to publish cloud box from my local box. The only way is to publish from local box file.

Imagine the situation, I want to build a new box(e.g. my/centos8) based on centos/8, that's what I do:

  1. Run a VM with box centos/8
  2. ssh to VM, and, install bundles of tools.
  3. Package the VM snapshot with vagrant package, we will get a local box file: package.box
  4. vagrant cloud create my/centos8 to create a new vagrant cloud box.
  5. vagrant cloud publish to publish box from package.box to vagrant cloud.

It's all seems pretty good enough. Let's go on. And then, how If I want to reuse my/centos8. Of course It's a good idea to use the version following from cloud box, so

  1. use vagrant box add my/centos8 to add box from cloud box to local box. Will be a long time....
  2. use my/centos8 to run a VM

But, why should I have to download from cloud box(cost me so much time), because I already have a local one. So, it's clever to use the local box file :package.box, so I can do

  1. use vagrant box add my/centos8 ./package.box to add box from local box file.
  2. use my/centos8 to run a VM

What is the problem? I add a box from local box file, and I publish a version to cloud box. There is no way to build relationship with the local box and the cloud box. So, if I want to follow the cloud box version? I have to download from cloud box again, and remove the local box(version 0) I have already added from local box file, which is absolutely the same with cloud box.

Think what it's done with docker? There is no such wierd situation.

spgyip avatar May 14 '21 03:05 spgyip

This requires allowing locally added boxes to be "linked" to a remote box (defaulting to Vagrant Cloud but able to be overriden to other remote source) as well as setting a version when adding the box. Ideally we'd want to validate the local box to the remote box (probably via checksum comparison) and have an override to ignore it as well.

chrisroberts avatar Jun 11 '21 17:06 chrisroberts

I think this use-case is handled by the Packer Vagrant builder: https://www.packer.io/plugins/builders/vagrant

The Vagrant builder is intended for building new boxes from already-existing boxes

jcmdln avatar Oct 08 '22 17:10 jcmdln