Book Image

Chef Infrastructure Automation Cookbook Second Edition

By : Matthias Marschall
Book Image

Chef Infrastructure Automation Cookbook Second Edition

By: Matthias Marschall

Overview of this book

Table of Contents (14 chapters)
Chef Infrastructure Automation Cookbook Second Edition
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

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
    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
  2. Tell the users of your cookbook which platforms...