Is it possible to get the box version when you are inside the VM?

32 views
Skip to first unread message

mike konovalov

unread,
Nov 24, 2019, 7:56:14 PM11/24/19
to Vagrant
In one of the scripts that I run inside VM I need to figure out what is the current box version.
Is it possible to bake this information inside VM somehow? Maybe some env vars or something?
Thanks

D Morgan

unread,
Nov 25, 2019, 1:59:26 PM11/25/19
to Vagrant
You have to pass the information in as part of the vagrant up/reload process.

Through a combination of the shell provisioner or file provisioner you can accomplish what you need

# Env Variable
config.vm.provision "shell", inline: "EXPORT box_version = ..."

or

# Text File
config.vm.provision "shell", inline: "echo box_version = ... > ~/bversion.txt"

or

#Hardcoded text file as part of some outside process
config.vm.provision "file", source: "~/bversion.txt", destination: "~/bversion.txt"
Reply all
Reply to author
Forward
0 new messages