Syntax question: User variables for non-string values

20 views
Skip to first unread message

Kevin Milner

unread,
Jan 31, 2018, 1:08:05 PM1/31/18
to Packer
Hello,
In my variables portion I want to be able to specify default values that can be overridden for disk_size, CPUs, and RAM (this is for jetbrains' vcenter builder plugin). In the builder section, I have this:
       "disk_size": 100,
      "CPUs": 4,
      "RAM": 8000,

and it works fine, but I want to be able to use variables in place.  However, if I put format as:
      "disk_size": {{user `vm_disk_size`}},
      "CPUs": {{user `vm_cpu`}},
      "RAM": {{user `vm_ram`}},

(No quotations around the value), the parser chokes because it doesn't know what to do with the brackets. I would expect this.
If I put the quotation marks around the values, however, I get the following error:
* variable vm_cpu: '' expected type 'string', got unconvertible type 'float64'

So it seems like I need to be able to denote this variable as a non-string type. Any idea how I do this?
Thanks

Rickard von Essen

unread,
Jan 31, 2018, 2:00:06 PM1/31/18
to packe...@googlegroups.com
I think you are reading the error message backwards. Packer converts the value to a number, but the plugin (which is unknown to me) expects a string. I think this is probably a bug in the plugin. 

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/mitchellh/packer/issues
IRC: #packer-tool on Freenode
---
You received this message because you are subscribed to the Google Groups "Packer" group.
To unsubscribe from this group and stop receiving emails from it, send an email to packer-tool+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/packer-tool/a0839d38-edea-4eed-be5f-f0b1ea614bee%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Kevin Milner

unread,
Jan 31, 2018, 2:03:31 PM1/31/18
to Packer
never mind, it was complaining on the variable declaration, not the builder.

Rickard von Essen

unread,
Jan 31, 2018, 2:04:47 PM1/31/18
to packe...@googlegroups.com
Hmm check the plugin and it looks correct. Can you share your template and command line when you get this error? 
Reply all
Reply to author
Forward
0 new messages