Similar to this question: Passing variable to a shell script provisioner in vagrant
I want to pass variables to a shell script provisioner but I want to set these va
In your Vagrantfile, add the following -
{
"PROVISION_PARAMS" => "some_default_values",
}.each { |key, value| ENV[key] = value if ENV[key] == nil }
These arguments can now be passed to shell script provisioner in the following way -
config.vm.provision :shell, privileged: true, run: "always",
:path => "../../scripts/script.ps1",
:args => ENV['PROVISION_PARAMS']
You can now provide command line arguments to this script in the following manner -
$ PROVISION_PARAMS=' param1 param2 "param 3" ' vagrant provision
And the script will take default values if these parameters are not specified.