Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to pass attributes in chef-client without JSON file?

Tags:

chef-infra

I know we can pass node attributes in chef-{client/solo} with --json-attributes(-j) flag. This flag always expect a JSON file as input. Is their any method I can directly pass the attributes as JSON objects.

I tried doing it. For eg:

chef-client -j {"attr":"value"} 

But it ends up with a failure message as:

FATAL: I cannot find {"attr":"value"}

As it expects a JSON file. I need to pass JSON objects as in our env I can't create a json file. I don't want to use attributes/role/environment files as well. Is there any other way to pass the attributes ?

like image 703
liondgr8 Avatar asked Feb 24 '14 11:02

liondgr8


1 Answers

Have you tried piping the JSON to STDIN?

echo '{"attr":"value"}' | chef-client -j /dev/stdin

like image 155
cassianoleal Avatar answered Nov 16 '22 01:11

cassianoleal