I am trying to pre-set a chef-attribute from a packer build but I can't seem to get it work:
"provisioners": [
{
"chef_environment": "test_cookbook",
"environments_path": "environments",
"execute_command": "{{if .Sudo}}sudo {{end}}chef-solo --no-color --legacy-mode -c {{.ConfigPath}} -j {{.JsonPath}}",
"json": {
"test_cookbook": {
"my_attr": "test"
}
},
"run_list": [
"test_cookbook"
],
"type": "chef-solo",
}
]
It is always getting passed as a nil value
output="#{Chef::Log.info(node['my_attr'])}"
log output
file "/tmp/#{node['my_attr']}" do
content output
end
I already referred this Using attributes in Chef Solo JSON already.