1

.kitchen.yml:

platforms:
 - name: win2012r2

suites:
  - name: example

Is it possible to get the running platform or suite name from within a recipe? I've tried node['platform'] and node['suite'] but both are empty.

Reed G. Law
  • 3,897
  • 1
  • 41
  • 78
  • 1
    I think this is possible through the use of ohai: https://docs.chef.io/ohai.html . If you install ohai as part of your converge then I think you can use the `node['platform']` like you wanted to. Also look at this: https://supermarket.chef.io/cookbooks/kitchen-ohai – caterpree Dec 12 '18 at 15:29
  • @Liam thanks for the suggestion but unfortunately with kitchen-ohai `node['platform']` evaluates to `windows` rather than the `.kitchen.yml` platform name. – Reed G. Law Dec 12 '18 at 19:56

2 Answers2

0

node['name'] evaluates to the suite name plus platform name joined by a hyphen (e.g. example-win2012r2).

Reed G. Law
  • 3,897
  • 1
  • 41
  • 78
0

you can use ohai:

Ohai is a tool that is used to collect system configuration data, which is provided to the chef-client for use within cookbooks.

you can have ohai load as a part of the ohai cookbook and then leverage it to retrieve the desired information. such as

node['platform']
node['platform_family']
node['kernel']['os']
Mr.
  • 9,429
  • 13
  • 58
  • 82
  • As I mentioned to @Liam above, that returns a generic platform name (e.g. "windows"). I'm interested in the specific name given in .kitchen.yml – Reed G. Law Dec 13 '18 at 21:49