Finding the complete list of operating systems you can use in cookbooks

You want to write cookbooks that work on different operating systems, such as Ubuntu, RedHat, Debian, or Windows.

Inside your cookbooks, you need to distinguish between these different platforms. And you need to tell your cookbook which platforms it supports. However, you don't know which platform values you can use inside metadata.rb or your recipes.

In this section, we'll look at a very simple way to ask Chef which values it defines for a platform.

How to do it...

Let's use plain Ruby to find out all the possible values for platform and use a subset of those in metadata.rb:

  1. Print a list of supported platforms by querying the Chef::Platform class:
    mma@laptop:~/chef-repo/cookbo ...

Get Chef: Powerful Infrastructure Automation now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.