I’m trying to create a Vagrantfile that any developer on my team can use for working with a particular code base as a development and test environment. But people put their source control repositories in whatever place they like on their development machines. So, the sync folder for that would be set up in the Vagrantfile might be different things depending on which developer is using it. I’m hoping there’s a way to let them set that up without having them edit the Vagrantfile. Possibly a separate config file?
Any help would be much appreciated.
In case anyone else comes here looking for the answer, a kind person on StackOverflow helped. I’m copying the response because apparently this kind of question goes better on a different site and the question might not be accessible…
You can customize additional synced folders with an additional line of code in the
Vagrantfile described here:
config.vm.synced_folder '<host_path>', 'guest_path'
This solves the problem of additional customized synced folders. However, you also stated you desired to customize this per user based on a config file. You can accomplish this with basic Ruby. We will assume the config file is YAML like:
Then we can read in the file with normal Ruby and utilize its key-value pairs as per normal. This assumes the file is in the same directory as where
vagrant commands are being executed; otherwise the code will need to be customized further:
paths = YAML.load_file('config.yaml')
config.vm.synced_folder paths['host_path'], paths['guest_path']
The code can also be easily modified for different config file formats.