【发布时间】:2019-02-12 16:37:37
【问题描述】:
我有一个厨师角色:
{
"name": "my-role",
"description": "Defines a role",
"override_attributes": {
"cookbook_one" {
"key": "value"
}
}
"run_list": [
recipe["cookbook_one"],
recipe["cookbook_two"]
]
}
我在提供程序块中使用 Packer 调用:
{
"variables": {
"my-variable": ""
},
"provisioners": [
{
"type": "chef-client",
"server_url": "https://mychefserver.com/",
"run_list": "role[my-role]",
...
}
我需要能够从 Packer 中向 recipe_two 添加一些属性。我读到我可以使用json block of the chef-client 配置器向运行列表添加一些属性。我试过了
"type": "chef-client",
"server_url": "https://mychefserver.com/",
"run_list": "role[my-role]",
"json": {
"override_attributes": {
"cookbook_two": {
"some_key": "value"
}
}
}
当我运行 packer 时,我可以在 /tmp/packer-chef-client/first-boot.json 中看到
{
"override_attributes": {
"cookbook_two": {
"some_key": "{{ user `my-variable` }}"
}
},
"run_list": [
"role[my-role]"
]
}
但是 recipe_two 的 override_attributes 不会暴露给食谱。我找不到任何关于如何让它以这种方式工作的示例,也找不到正确的“json”格式:{} 块通过。
非常感谢通过从 Packer 调用的角色向我的食谱公开被覆盖属性的任何方向
【问题讨论】:
标签: chef-infra chef-recipe packer