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.
Let's use plain Ruby to find out all the possible values for platform
and use a subset of those in metadata.rb
:
Print a list of supported platforms by querying the
Chef::Platform
class:mma@laptop:~/chef-repo/cookbo oks $ ruby -rchef -e 'puts Chef::Platform.platforms.keys.sort.join(", ")'
aix, amazon, arch, centos, cloudlinux, debian, default, exherbo, fedora, ...TRUNCATED OUTPUT... ubuntu, windows, xcp, xenserver
Tell the users of your cookbook which platforms...