我的.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['web']['app']['name'] = nil
default['web']['app']['zip'] = nil
我的默认配方在开始时会检查是否在继续执行脚本之前设置了属性,请使用以下方法进行操作:
配方/default.rbruby_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
,kitchen将启动我的Windows Server 2012 R2
VM并成功部署我的应用程序(属性起作用)。完成该平台后,厨房将再次为我的Windows Server 2008 R2
VM重新开始该过程。虽然,此时它会引发我在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.
将其复制下来,因为它是答案:在测试实例上添加,删除或更改属性数据时,您需要销毁并重新创建该实例。属性数据是在创建阶段收集和缓存的,因此仅重新运行converge
将不会执行任何操作。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句