2016-08-18 31 views
0

我试图使用dsc_authenticationinfo => {"Anonymous"=>false, "Basic"=>false, "Digest"=>false, "Windows"=>true},得到could not evaluate错误下面。此属性位于dsc_xwebsite {}内部。木偶DSC模块:无法评估:从类型'INSTANCE []'转换属性'认证信息'值以键入'INSTANCE'失败

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 
+0

好的,我在这个潜在的方向上走错了方向。你的'$ app_dns_name'作为字符串传递吗?它应该像'$ app_dns_name ='ls-dev.domain.com''而不是'$ app_dns_name = ls-dev.domain.com'。顺便说一句,根据dsc_xwebsite类型的源代码,你的'dsc_bindinginfo'可能是一个散列而不是散列数组。 –

+0

不,它不是ls-dev.domain.com。它应该是tools-dev.domain.com - 但由于某种原因,错误信息也会“切断”。 Puppet通过hiera查找将$ app_dns_name作为字符串带入。我相当肯定查找是正确完成的,因为其他事情正在正确使用该变量。 – FuriousD

回答

0

这是一个问题1)文档对微软的DSC代码。 2)在puppetlabs \ dsc模块中执行不当。 MS文档已修复,DSC模块从版本1.2.0开始固定。

0

我不熟悉的木偶语法,但你的傀儡代码比较下面的一些工作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 []’到 类型‘实例’失败”

表示要传递的阵列当单个authenticationinfo预期?您的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 
       } 
    } 
+0

谢谢凯文。不幸的是,我已经尝试过,没有引号周围的认证属性和有和没有括号,但不能让它在傀儡工作。 感谢您的语法。它在DSC中工作。我不确定这是否是木偶模块中的一个错误。 – FuriousD

+0

xwebadministration的github上的文档说bindinginfo和authenticationinfo都是数组。 – FuriousD

+0

FWIW,我认为DSC文档说AuthenticationInfo是一个数组是错误的。看看[源代码](https://github.com/PowerShell/xWebAdministration/blob/dev/DSCResources/MSFT_xWebsite/MSFT_xWebsite.schema.mof),第31行和第34行,我看到一个BindingInfo []类型和AuthenticationInfo类型,没有括号。我会向他们提出有关文档的问题。 – KevinC

相关问题