How to specify variable for 'bool' item

19 views
Skip to first unread message

Yusuke Masuda

unread,
Oct 5, 2019, 6:57:47 PM10/5/19
to Packer
Hi.

I want to specify a variable for 'bool' type item such as "keep_input_artifact".

Firstly, I tried this.
  "keep_input_artifact": "{{user `keep_input_artifact`}}",
   
:
   
:
 
"variables": {
   
"keep_input_artifact": true,
 
}

Then I got an error below.
Failed to parse template: 2 errors occurred:
        * variable keep_input_artifact: '' expected type 'string', got unconvertible type 'bool'
        * post-processor 1.1: 1 error(s) decoding:
* 'keep_input_artifact' expected type 'bool', got unconvertible type 'string'

It seems to say that it is wrong to specify the string value to 'bool' type.

Next I tried removing the quotes.
  "keep_input_artifact": {{user `keep_input_artifact`}},
   
:
   
:
 
"variables": {
   
"keep_input_artifact": true,
 
}

So I got another error below.
Failed to parse template: Error parsing JSON: invalid character '{' looking for beginning of object key string
At line 42, column 34 (offset 1204):
   41:         "type": "vagrant",
   42:         "keep_input_artifact": {{
                                       ^

The error was a kind of JSON syntax error, seemed that it interpret the bracket for template as a part of JSON object.

I wonder I cannot use a variable for not string fields.
Please give me any advice for this, if you have.

Sincerly,

Yusuke

Rickard von Essen

unread,
Oct 6, 2019, 3:31:12 PM10/6/19
to packe...@googlegroups.com

--
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...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/packer-tool/81b07ab2-bea2-4ccb-b9c4-4f81641a4bb0%40googlegroups.com.

Yusuke Masuda

unread,
Oct 6, 2019, 7:52:36 PM10/6/19
to Packer
Thank you for informing it.
I understood this is a known issue, and it is difficult to fix without architectural improvement.

Will wait for new version rolling out.

Thanks,

Yusuke.

Reply all
Reply to author
Forward
0 new messages