sous-chefs/iis

Wrapper Cookbook Attributes and DISM

0ni0nrings opened this issue · 2 comments

Cookbook version

7.1.1

Chef-client version

14.6.47

Platform Details

Windows Server 2016

Scenario:

  1. Calling recipes from source cookbook in a wrapper cookbook
  2. Why is the source cookbook dependent on DISM only?

Steps to Reproduce:

Write a wrapper cookbook, setup attributes to run IIS out of D drive and it wont override the default.
Attempt to install using Add-WindowsFeature instead of DISM.

Expected Result:

  1. attributes in wrapper/attributes to override default attributes.
  2. there's should be an explanation or usage on how to use Add-WindowsFeature instead of DISM.

Actual Result:

I tried the wrapper cookbook, adjusted attributes, edited metadata.rb and called one recipe from original cookbook and that failed, i.e.. it didn't make any difference in the execution.

  1. I downloaded the IIS vendor cookbook
  2. I downloaded the windows dependency
  3. I generated a wrapper cookbook
  4. In wrapper cookbook's metadata I put in depends 'IIS'
  5. in wrapper cookbook's attributes, I put in my changes as I want to run the site from D rather than C so it looks like

default['iis']['home'] = "#{ENV['WINDIR']}\System32\inetsrv"
default['iis']['conf_dir'] = "#{ENV['WINDIR']}\System32\inetsrv\config"
default['iis']['pubroot'] = "D:\inetpub"
default['iis']['docroot'] = "D:\inetpub\wwwroot"

  1. under wrapper cookbook's default recipe, I put in include_recipe 'IIS::default'
  2. then I try to run wrapper cookbook in --local-mode

Uses DISM instead of PowerShell (Add-WindowsFeature) to install additional features.

[2018-12-12T12:50:29+13:00] INFO: Storing updated cookbooks/wrapper/attributes/default.rb in the cache.

  • wrapper (0.1.0)
  • iis (7.1.1)
  • windows (5.2.2)
    Installing Cookbook Gems:
    Compiling Cookbooks...
    Converging 2 resources
    Recipe: iis::default
  • iis_install[install IIS] action install[2018-12-12T12:50:29+13:00] INFO: Processing iis_install[install IIS] action install (iis::default line 21)

    • windows_feature[IIS-WebServerRole, Web-Common-Http, Web-Default-Doc, Web-Dir-Browsing] action install[2018-12-12T12:50:29+13:00] INFO: Processing windows_
      feature[IIS-WebServerRole, Web-Common-Http, Web-Default-Doc, Web-Dir-Browsing] action install (c:/users/USER/.chef/local-mode-cache/cache/cookbooks/iis
      /resources/install.rb line 26)

      • windows_feature_dism[IIS-WebServerRole, Web-Common-Http, Web-Default-Doc, Web-Dir-Browsing] action install[2018-12-12T12:50:29+13:00] INFO: Processing w
        indows_feature_dism[IIS-WebServerRole, Web-Common-Http, Web-Default-Doc, Web-Dir-Browsing] action install (C:/opscode/chef-workstation/embedded/lib/ruby/gems/2.
        5.0/gems/chef-14.6.47-universal-mingw32/lib/chef/resource/windows_feature.rb line 83)

        ================================================================================
        Error executing action install on resource 'windows_feature_dism[IIS-WebServerRole, Web-Common-Http, Web-Default-Doc, Web-Dir-Browsing]'

        RuntimeError

        The Windows features web-common-http,web-default-doc,web-dir-browsing are not available on this version of Windows. Run 'dism /online /Get-Features' to
        see the list of available feature names.

        Resource Declaration:

        In C:/opscode/chef-workstation/embedded/lib/ruby/gems/2.5.0/gems/chef-14.6.47-universal-mingw32/lib/chef/resource/windows_feature.rb

        83: declare_resource(subresource, new_resource.name) do
        84: action desired_action
        85: feature_name new_resource.feature_name
        86: source new_resource.source if new_resource.source
        87: all new_resource.all
        88: timeout new_resource.timeout
        89: management_tools new_resource.management_tools if subresource == :windows_feature_powershell
        90: end
        91: end

        Compiled Resource:

        Declared in C:/opscode/chef-workstation/embedded/lib/ruby/gems/2.5.0/gems/chef-14.6.47-universal-mingw32/lib/chef/resource/windows_feature.rb:83:in `r

un_default_subresource'

    windows_feature_dism("IIS-WebServerRole, Web-Common-Http, Web-Default-Doc, Web-Dir-Browsing") do
      action [:install]
      default_guard_interpreter :default
      declared_type :windows_feature_dism
      cookbook_name "iis"
      feature_name ["iis-webserverrole", "web-common-http", "web-default-doc", "web-dir-browsing"]
      all true
      timeout 600
    end

    System Info:
    ------------
    chef_version=14.6.47
    platform=windows
    platform_version=10.0.14393
    ruby=ruby 2.5.1p57 (2018-03-29 revision 63029) [x64-mingw32]
    program_name=C:/opscode/chef-workstation/bin/chef-client
    executable=C:/opscode/chef-workstation/bin/chef-client

[2018-12-12T12:50:33+13:00] INFO: Running queued delayed notifications before re-raising exception

  ================================================================================
  Error executing action `install` on resource 'windows_feature[IIS-WebServerRole, Web-Common-Http, Web-Default-Doc, Web-Dir-Browsing]'
  ================================================================================

the iis_install resource utilizes the following code: https://github.com/chef-cookbooks/iis/blob/master/resources/install.rb

if you are specifying addition components that is likely where the issue is, i recommend looking at the error and running the command it recommends to see if one of the features isn't available. That resource doesn't support installing via any other method but feel free to add it as a Pull Request.

IIS-WebServerRole, Web-Common-Http, Web-Default-Doc, Web-Dir-Browsing can you search for IIS- as well since that is the IIS-WebServerRole. I think you only really need IIS-WebServerRole for what you are doing but i might be mistaken.

To add Powershell you would need to add the option for install method...then you'd need an if statement basically to decide which method to use to install them. This also means looking up the items that need to be installed and making those the default. You should be able to reuse the default['iis']['components'] = [] attribute