I am new to Chef and Ruby
I need to pass two variables to Chef on the command line and have those variables available in a recipe.
How I can capture these va
You can set variables inside recipes by calling commands
nodename = `cat /etc/chef/client.rb | grep "node_name" | sed -e 's/\//g' | sed '/^$/d;s/[[:blank:]]//g' | sed 's/\"//g'`
And then use the variable for other chef blocks
execute "echo nodename for node #{nodename}"
command "echo #{nodename}"
action :run
only_if {nodename == "node1"}
end
This will get the node.name attribute from the client.rb file without asking for it to the chef server.