Sometimes, you need to handle more complex situations, such as supporting distinctly different operating systems, such as Linux and Windows. This can easily be handled by subclassing your Custom Resource. Let's consider a new requirement for our use case, that is, we need to extend our new appsite Custom Resource cookbook so that it will allow us to create websites on OS X and Linux using Apache, and on Windows using IIS.
In order to provide for subclassing of our Custom Resource, we will need to convert them into a library module, so let's start there.
We begin by creating a new folder named "libraries" in our cookbook. Next, we create a new file in our libraries folder named website.rb
and add the following contents to the file:
module AppsiteCookbook class Website < Chef::Resource resource_name :appsite_website end end
This is the template used to define our library module. We are creating a new library module...