-
Notifications
You must be signed in to change notification settings - Fork 3.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
user variables not working in vagrant post provisioner when using vagrantfile.template #12682
Comments
|
Hi @jamesla user variables within the vagrant template file is not something that is supported. Only the following template variables are allowed for use with a vagrant template: {{ .BoxName }}, {{ .SyncedFolder }}, and {{.InsertKey}}, which correspond to the Packer options box_name, synced_folder, and insert_key. Alternatively, the template variable {{.DefaultTemplate}} is available for use if you wish to extend the default generated template. Since you are looking to create a template with custom variable data I recommend you take a look at the templatefile function for generating the vagrant file. locals {
vagrantfile = {
"path/to/Vagrantfile.template" = templatefile("${path.root}/vagrantfile.pkrtpl", var.some_variable)
}
}
post-processor "vagrant" {
vagrantfile_template = local.vagrantfile
} If you're struggling to get Packer working for the first time, I'd recommend reaching out to the community forum for help. The GitHub issue tracker is only watched by a small subset of maintainers and is really reserved for bugs rather than questions. You'll have a better chance of finding someone who can help you in the forum. I'm going to close this issue as it is not a bug but feel free to reach out if you run into an issue with the templatefile function that you believe may be a bug. |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. |
I have configured a variable in my packer file like so:
configuring my vagrant post provisioner like this:
and trying to interpolate the variable like this in my vagrantfile.template
and get the following error:
The docs are very limited in terms of this functionality - am I doing this right? How is it supposed to work?
The text was updated successfully, but these errors were encountered: