From c1d103348ddf36f2ad45cd71d3a2596fdbf333e8 Mon Sep 17 00:00:00 2001 From: Evgeni Golov Date: Thu, 1 Dec 2016 13:58:40 +0100 Subject: [PATCH] add a way to inject data into the Vagrantfile for example, I have to set a few settings for my box: % cat Vagrantfile.add config.vm.provider :libvirt do |libvirt| libvirt.nic_model_type = "e1000" libvirt.disk_bus = "sata" end config.vm.guest = :tinycore % create_box.sh my.qcow2 my.box Vagrantfile.add --- tools/create_box.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tools/create_box.sh b/tools/create_box.sh index dd48245..4b5db91 100755 --- a/tools/create_box.sh +++ b/tools/create_box.sh @@ -8,7 +8,7 @@ error() { } usage() { - echo "Usage: ${0} IMAGE [BOX]" + echo "Usage: ${0} IMAGE [BOX] [Vagrantfile.add]" echo echo "Package a qcow2 image into a vagrant-libvirt reusable box" } @@ -62,6 +62,10 @@ mkdir -p "$TMP_DIR" [[ ! -r "$IMG" ]] && error "'$IMG': Permission denied" +if [ -n "$3" ] && [ -r "$3" ]; then + VAGRANTFILE_ADD="$(cat $3)" +fi + # We move / copy (when the image has master) the image to the tempdir # ensure that it's moved back / removed again if [[ -n $(backing "$IMG") ]]; then @@ -107,6 +111,8 @@ Vagrant.configure("2") do |config| libvirt.storage_pool_name = "default" end + +${VAGRANTFILE_ADD:-} end EOF