Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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 git@github.com/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 git@github.com/blah -b

~Git error showing options and appropriate input~

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

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

How do I load in my passed JSON attribute? I am using Chef 11, but the client is 10.18.2. However, the documentation states that it is still compatible with Chef 11.

Edit: I have followed Is there a way to pass parameters at run time in Chef?, but the JSON is still not being passed, or accessed.

I printed out node.keys in my recipe that is being called and I don't see the branch attribute listed.

So maybe the JSON isn't until after the run list, or the JSON attribute just isn't being loaded in at all.

EDIT2:

The JSON is definitely not being loaded. first-boot.json file doesn't contain whatever JSON parameters I am passing via knife ec2.

share|improve this question
    
Are you using this exact switch: -j '{"branch':'clone'} ? Because this is not valid JSON! Anyway, using -j '{ "branch": "clone" }' should make it accessible via node['branch'] –  Panagiotis PJ Papadomitsos Mar 29 '13 at 0:58
    
Ah I apologize for the mistyping. I am indeed using -j '{"branch" : "clone"}'. –  user1002563 Mar 29 '13 at 13:34

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.