2016-10-11 28 views
1

我遇到了.kitchen.yml文件的問題。我希望我的屬性能夠加載我的平臺的所有全部,但相反,它只能加載我的平臺的一個。這就是我的.kitchen.yml文件內容是這樣的:廚房屬性只能在一個平臺上工作

.kitchen.yml
--- 
driver: 
    name: vagrant 
    gui: true 

provisioner: 
    name: chef_zero 

transport: 
    name: winrm 
    elevated: true 

platforms: 
    - name: win2012r2-standard 
    driver: 
     box: eltuko/win2012r2-chef-pester 
     customize: 
     memory: 2048 
    - name: win2008r2-standard 
    driver: 
     box: charris/windows-2008-r2-x64 
     customize: 
     memory: 2048 

suites: 
    - name: default 
    run_list: 
     - recipe[xxx] 
     - recipe[yyy] 
    attributes: 
     web: 
     app: 
      name: "MyApp" 
      zip: "MyApp.zip" 
     chef_client: 
     config: 
      log_level: ":debug" 

需要更多的環境?

我的食譜需要設置2個屬性才能使其工作。默認情況下,這些屬性值設置爲nil

屬性/ default.rb
default['web']['app']['name'] = nil 
default['web']['app']['zip'] = nil 

我的默認配方檢查,一開始,這個屬性是繼續腳本之前設置,我這樣做是使用以下:

食譜/默認。 RB
ruby_block 'Check if node is configured correctly' do 
    block do 
    raise 'app name is not set.' if node['web']['app']['name'].nil? 
    raise 'app zip is not set.' if node['web']['app']['zip'].nil? 
    end 
end 

當我運行kitchen converge,廚房推出我的Windows Server 2012 R2 VM,併成功地部署我的應用程序(屬性工作)。一旦該平臺完成,廚房然後再次啓動整個程序爲我的Windows Server 2008 R2虛擬機。雖然在這一點上它拋出了我在我的recipes/default.rb文件中創建的異常。

我收到以下錯誤Windows Server 2008 R2 VM:

控制檯日誌
================================================================================ 
Error executing action `run` on resource 'ruby_block[Check if node is configured correctly]' 
================================================================================ 

    RuntimeError 
    ------------ 
    app name is not set. 
+4

如果您在創建虛擬機後添加了屬性數據,請確保您運行完整的破壞和重新創建循環(即「廚房測試」)。否則你看起來是正確的。 – coderanger

+1

@coderanger哇!謝謝,運行'廚房測試'工作!我還用「廚房摧毀2008」和「廚房融合2008」對它進行了測試,就像一種魅力!我只是這麼拋棄爲什麼'Windows Server 2012 R2'工作,但不是'Windows Server 2008 R2'。謝謝! +1 – Pwnzo

回答

2

複製下來,因爲這是答案:當你添加,刪除或更改的屬性數據您需要銷燬並重新創建該實例的測試實例。屬性數據在創建階段被收集和緩存,因此只需重新運行converge將不會執行任何操作。

相關問題