I'm looking for a way to pass parameter to Chef cookbook like:
$ vagrant up some_parameter
And then use some_parameter
inside one of the Chef cookbooks.
I'm looking for a way to pass parameter to Chef cookbook like:
$ vagrant up some_parameter
And then use some_parameter
inside one of the Chef cookbooks.
You cannot pass any parameter to vagrant. The only way is to use environment variables
And use
ENV['MY_VAR']
in recipe.It is possible to read variables from ARGV and then remove them from it before proceeding to configuration phase. It feels icky to modify ARGV but I couldn't find any other way for command-line options.
Vagrantfile
provision.sh
You also can include the GetoptLong Ruby library that allows you to parse command line options.
Vagrantfile
Then, you can run :
Note: Make sure that the custom option is specified before the vagrant command to avoid an invalid option validation error.
More information about the library here.