0

I'm working with Chef and Test Kitchen, I have some problems installing Apache 2.2 and I was reading the cookbook with my recipe (https://github.com/sous-chefs/apache2/blob/master/recipes/default.rb), I would like to know how this recipe is working when installed Apache and I want print some variables when I launch my recipe:

node['platform_family']
node['platform_version']

An example from Chef official doc:

Chef::Log.fatal('You did not accept the license (set node["splunk"]["accept_license"] to true)')

But I write in my recipe:

Chef::Log.info('PERSONAL-LOG,node["platform_family"]')

I get the log, but exactly with the same text I write, I cant concatenate or call the var directly.

Can someone help me?

BigBugCreator
  • 1,009
  • 4
  • 17
  • 34

1 Answers1

2

Its a case of ruby string interpolation, please use it as:-

Chef::Log.info("PERSONAL-LOG, #{node['platform_family']}")

http://ruby-for-beginners.rubymonstas.org/bonus/string_interpolation.html

  • I neither could with that method, but I find something easier: puts node['platform_family'] To find problems its ok. – BigBugCreator Mar 23 '17 at 10:32
  • Chef Logging call make the log as part of chef run, but a simple puts will print out at compile time itself. Both are good. Can you help to explain what you are running. You may also want to refer: - http://stackoverflow.com/questions/38984083/how-do-i-get-log-output-in-test-kitchen – Mrigesh Priyadarshi Mar 23 '17 at 13:09