Set environment variable using output from script?

I have a bash script that does a md5 on a file and I would like to set an environment variable based on the output of that file. Its used for versioning, so we calculate the md5 and then set then start the webapp (Ruby On rails), that reads the environment variable. Can I do this in packer?

I use Ansible and its on Linux.

To clarify, do you want to set the md5 value as an environment var to be used in a future provisioner?

Most provisioners operate within their own contexts, so setting an environment variable from one won’t work. What you can do, is have your script output a dotfile containing the variables you want to source, and have your script in your next provisioner source it.

1 Like

I see. Ill have the WEBAPP itself call the method to get the version then. Thanks for the help