vagrant
vagrant copied to clipboard
Publish vagrant cloud from local box
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:
- Run a VM with box
centos/8 - ssh to VM, and, install bundles of tools.
- Package the VM snapshot with
vagrant package, we will get alocal box file:package.box vagrant cloud create my/centos8to create a new vagrant cloud box.vagrant cloud publishto publish box frompackage.boxto 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
- use
vagrant box add my/centos8to add box fromcloud boxtolocal box. Will be a long time.... - use
my/centos8to 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
- use
vagrant box add my/centos8 ./package.boxto add box fromlocal box file. - use
my/centos8to 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.
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.
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