How to load JSON attributes through a knife through chef recipes?

I have a web server that basically accepts input for the ec2 server command for the knife.

In the team of my knife I went

-j '{"branch":"clone"}'

From the documentation, I thought I could do it in my downloadable recipes:

@@branch = node['branch']
...
git clone git@github.com/blah -b #{@@branch}

However, git clones do not work because it @@branchdoes not return. Or at least the chef's magazines say start the output:

git clone git@github.com/blah -b

~Git error showing options and appropriate input~

How to load in my passed JSON attribute? What is the right way?

Edit:

I manually insert the knife command and the JSON attributes seem to load using the Ruby hash instead of JSON

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

Last Modified:

My team:

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]'

The answer is below.

+5
source share
1 answer

, , -d ubuntu-12.04, ec2 load -j json-attributes.

-d. Json .

+4

All Articles