Information Technology Reference
In-Depth Information
There's one more thing we need to cover before you can go about using all of the Serverspec
resources in your own test code. Many Serverspec resources require Serverspec to detect in-
formation about the test node operating system so it can run the correct commands for the
platform. We've taken care so far not to use any commands that need this extra support.
The package resource is a command that requires Serverspec to detect OS information. Fig-
ure 16-13 shows the documentation from the Serverspec site on the service resource. It can
be used to detect whether a package is installed. Behind the scenes, it needs to know what
OS is being used so it can use the rpm -q command on RedHat and variants or dpkg-query
on Ubuntu/Debian to perform this query, for example.
Figure 16-13. Serverspec package resource
By default, Serverspec tries to automatically detect the OS, which works for most Linux/
Unix variants. However, on some platforms you'll need to override the default OS setting,
using the set method.
In particular, you'll need to add the following line to all your _spec.rb files for test code that
you plan to run on Windows guests, as Serverspec is unable to automatically detect the Win-
dows OS, as of this writing. The exact set commands needed vary by platform. Refer to the
Serverspec documentation for more information.
Search WWH ::




Custom Search