I'm using Vagrant boxes for several purposes, and in most cases the prepared boxes I can download are totally sufficient. However, sometimes I need one or a few additional packages installed on the box—for regular activities, not one-time use.
For example, I have a Vagrant box on my Mac (Linux guest on Mac host) which I primarily want for easy access to built-in Linux documentation (
info pages, etc.) However, the box I am using doesn't have the
man package installed when I first
If I just install the package manually, it will only last until the next
vagrant destroy. If I use
vagrant halt instead, I'll build up cruft on my system, which defeats the purpose of using
vagrant as opposed to simply a Virtual Box.
I know the general answer to this is vagrant provisioning, and it could be as simple as a script with a single command
sudo yum install man. (Although actually I don't even know specifically how to do that.) However, rather than downloading the man package and all dependencies each time I start the vagrant box, I would rather download those packages once, store them on my host system, and load them into the vm each time I
I have already run
sudo yum install man --downloadonly on the guest, to get the packages I need, and
sudo cp -r /var/cache/yum/x86_64/6/base/packages/ /vagrant/ to put the package files on my host.
So my question is really twofold:
What is the vagrant provisioning syntax to use for: (a) calling a script (to be stored in the same directory as the Vagrantfile), or (b) if possible, embedding a single command in the Vagrantfile (such as
sudo yum install man)?
How can I give
yumthe option flags needed to install a package from a local directory (
/vagrant) and to install any needed dependencies from that same local directory rather than from an online repository?