Puppet DSC 模块:无法评估:将 属性 'authenticationinfo' 值从类型 'INSTANCE[]' 转换为类型 'INSTANCE' 失败

Puppet DSC module: Could not evaluate: Convert property 'authenticationinfo' value from type 'INSTANCE[]' to type 'INSTANCE' failed

我正在尝试使用 dsc_authenticationinfo => {"Anonymous"=>false, "Basic"=>false, "Digest"=>false, "Windows"=>true},,但出现以下 could not evaluate 错误。此 属性 在 dsc_xwebsite{} 内。

dsc_xwebsite{$app_dns_name:
  dsc_ensure                    => 'Present',
  dsc_name                      => $app_dns_name,
  dsc_state                     => 'Started',
  dsc_physicalpath              => $app_webroot_path,
  dsc_applicationpool           => $app_pool_name,
  dsc_bindinginfo               => [{
    protocol => 'HTTP',
    port     => 80,
    hostname => $app_dns_name,
  }],
  dsc_authenticationinfo => {"Anonymous"=>true, "Basic"=>true, "Digest"=>true, "Windows"=>true},
}

我的 windows 2012 R2 主机出现以下错误。

Error: /Stage[main]/Profiles::Iis_tools/Dsc_xwebsite[tools-dev.domain.com]: Could not evaluate: Convert property 'authenticationinfo' value from type 'INSTANCE[]' to type 'INSTANCE' failed
 At line:31, char:2
 Buffer:
ls-dev.domain.com";
};^

insta

我不熟悉 Puppet 语法,但是将您的 puppet 代码与下面的一些工作 DSC 进行比较,您的身份验证代码的格式似乎应该更像您的绑定代码,所以

dsc_authenticationinfo => 
  {"Anonymous"=>true, "Basic"=>true, "Digest"=>true, "Windows"=>true},

应该是:

dsc_authenticationinfo => 
  {dsc_anonymous => true, dsc_basic => true, dsc_digest => true, dsc_windows => true},

但是,您的错误信息:

"Convert property 'authenticationinfo' value from type 'INSTANCE[]' to type 'INSTANCE' failed"

表示您在需要单个身份验证信息时传递数组?您的 dsc_authenticationinfo 值不在方括号中,这对我来说是正确的;我希望您发布的代码和错误消息不同步,上面的代码更改将解决您的问题。

作为参考,这是有效的 DSC 代码。并注意 BindingInfo 是一个数组,而 AuthenticationInfo 是单个实例:

  xWebSite DefaultWebSite_Site
  {
       Name = "Default Web Site"
       Ensure = "Present"
       State = "Started"
       ApplicationPool = "DefaultAppPool"
       PhysicalPath = "%SystemDrive%\inetpub\wwwroot"  # must already exist
       LogPath = "D:\IISLogs"
       DependsOn = "[xWebAppPool]DefaultAppPool_Pool"
       BindingInfo = 
                 @(
                      MSFT_xWebBindingInformation 
                      {
                           Protocol = "http"
                           Port = "80"
                           IPAddress = "*"
                      }
                 )
       AuthenticationInfo = 
                 MSFT_xWebAuthenticationInformation 
                 {
                      Anonymous = $true
                      Basic = $false
                      Digest = $false
                      Windows = $false
                 }
  }

这是 1) Microsoft DSC 代码文档的问题。 2) puppetlabs\dsc 模块中的不正确实现。从 1.2.0 版开始,MS 文档已修复,DSC 模块已修复。