傀儡 DSC 模块:无法计算:将属性'authenticationinfo'值从类型 'INSTANCE[]' 转换为类型 'INSTANCE' 失败



我试图使用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},

但是,你的错误信息:

"将属性'authenticationinfo'的值从类型'INSTANCE[]'转换为type 'INSTANCE' failed"

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

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

  xWebSite DefaultWebSite_Site
  {
       Name = "Default Web Site"
       Ensure = "Present"
       State = "Started"
       ApplicationPool = "DefaultAppPool"
       PhysicalPath = "%SystemDrive%inetpubwwwroot"  # 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
                 }
  }

这是微软DSC代码文档中的一个问题。2) puppetlabsdsc模块实现不当。MS文档是固定的,DSC模块从1.2.0版本开始是固定的。

相关内容

最新更新