HCL2 conversion question

84 views
Skip to first unread message

J Jones

unread,
Apr 3, 2021, 9:41:29 AM4/3/21
to Packer
For the chef-client  Provisioner , I currently use something like this for the json option:

"json": {
            "test_a": {
                "product_1": 
                {"version": "1.00.00"},
                
                "product_2":
                {"version": "1.01.00}
             }
        }

Everything that try when switching to HCL2 doesn't work.  

Any help would be appreciated.
thanks

Sylvia Moss

unread,
Apr 3, 2021, 10:14:08 AM4/3/21
to Packer

For HCL2 templates you must use the json_string option. It will be like:
json_string = jsonencode({ 
   "test_a" = {
            "product_1" = {"version" = "1.00.00"}
            "product_2" = {"version" ="1.01.00"}
     }
  })


Scott M

unread,
Apr 5, 2021, 8:13:37 AM4/5/21
to Packer
While this looks like it would work for chef-solo, if I use it for chef-client, I get:
Unsupported argument; An argument named
"json_string" is not expected here.

Sylvia Moss

unread,
Apr 6, 2021, 4:41:14 AM4/6/21
to Packer
You're right! Sorry, I didn't notice you weren't using the chef-solo. The same attribute must be implemented to chef-client too. Do you mind opening an issue for that? 
https://github.com/hashicorp/packer/issues
Reply all
Reply to author
Forward
0 new messages