如何通过厨师食谱加载JSON属性?

use*_*563 5 attributes chef-infra knife

我有一个Web服务器,基本上接受刀ec2 create server命令的输入.

在我的刀具命令中,我传入

-j '{"branch":"clone"}'
Run Code Online (Sandbox Code Playgroud)

从文档中我认为我可以在我正在加载的食谱中执行此操作:

@@branch = node['branch']
...
git clone git@github.com/blah -b #{@@branch}
Run Code Online (Sandbox Code Playgroud)

但是,git克隆失败,因为@@branch没有返回.或至少厨师日志说开始输出结果:

git clone git@github.com/blah -b

~Git error showing options and appropriate input~
Run Code Online (Sandbox Code Playgroud)

如何加载我传递的JSON属性?什么是正确的方法?

编辑:

我手动输入了knife命令,并且JSON属性似乎使用Ruby哈希而不是JSON加载

JSON Attributes: {"branch"=>"Air"}

最后编辑:

我的命令:

sudo knife ec2 server create -x ubuntu -i ~/.ssh/key.pem -I ami-0eca6e67 -d ubuntu-12.04 -j '{ "branch" : "clone" }' -Z us-east-1a -s subnet-6827ec00 -f c1.medium -g sg-bc9d86d0 -r 'role[role]'

答案如下.

use*_*563 4

因此,如果我使用已经存在的引导模板,-d ubuntu-12.04knife ec2 不会加载-j json-attributes。

去掉 -d 选项。Json 正确加载。