2016-08-18 48 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