Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I load JSON attributes pass via knife through chef recipes?

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

In my knife command, I pass in

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

From documentation I thought I would be able to do this in my recipes that are being loaded:

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

However, the git clones are failing because @@branch doesn't return. Or atleast the chef logs say begin output of result:

git clone [email protected]/blah -b

~Git error showing options and appropriate input~

How do I load in my passed JSON attribute? What is the correct way?

Edit:

I manually put in the knife command, and the JSON Attributes seem to load using Ruby hash instead of JSON

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

Last Edit:

My command:

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

Answer below.

like image 414
user1002563 Avatar asked Oct 05 '22 14:10

user1002563


1 Answers

So it seems if I use a bootstrap template that already exists, -d ubuntu-12.04, knife ec2 does NOT load -j json-attributes.

Get rid of the -d option. Json loads appropriately.

like image 184
user1002563 Avatar answered Oct 13 '22 10:10

user1002563