Chef Windows Managing Roles And Features
Similar to how Linux distributions have package management tools and a repository of packages, Windows has long had built-in packages that come with the OS. Both desktop and server releases of Windows have installable components out of the box, with servers having more than desktops.
In Windows parlance, roles are similar to Chef's notion of rolesa collection of software packages and services that work together to provide a certain set of functionality such as web application services or DNS. Multiple services can be required to provide a particular role on a Windows server. However, because these roles are managed as part of Windows, the level of control that you have over them is somewhat limited through Chef. You can enable or disable them through the windows_feature resource, but Windows (instead of Chef) determines what gets installed.
Features, on the other hand, are more like packages; they provide functionality that may not be critical to participating in a particular role, or may not even be related to roles in general. Chef refers to both roles and features as features, and the windows_ feature resource provides a mechanism for managing both of these through Chef.
There are currently two providers for windows_feature: Deployment Image Servicing and Management (DISM) and servermanagercmd (the server manager command-line tool). The servermanagercmd command is deprecated in favor of DISM as the recommended mechanism for managing roles and features. Therefore, the default provider used by Chef is DISM if it is present on the system being managed, falling back to using servermanagercmd if it is not.
For a complete list of all roles and features that are available on a node, use one of the following mechanisms. On DISM-enabled systems, run the dism command as follows:
dism /online /Get-Features
The output of this command gives you a list of features and their current status. The following screenshot is an excerpt from the output obtained on running this command on a host:
Here, the Feature Name key would be used to map to the feature_name attribute in the windows_feature resource. For hosts without DISM, use the servermanagercmd tool as follows:
servermanagercmd -query
The output of this command would look like the following screenshot:
In the preceding screenshot, the string in square brackets would be the value to supply to the feature_name attribute to manage that component. In order to install these, Chef provides us with the windows_feature resource, which is described in the following table: