【发布时间】:2015-12-19 09:08:30
【问题描述】:
我有以下问题。下面的厨师食谱代码 sn-ps 的行为并不相同,尽管它们在纯逻辑方面对我来说看起来是一样的。
template "Create a file if not exists" do
path "#{site_docroot}/somefile.php"
source 'somefile.php.erb'
action :create_if_missing
end
VS.
if !File.exists? "#{site_docroot}/somefile.php"
template "Create a file if not exists" do
path "#{site_docroot}/somefile.php"
source 'somefile.php.erb'
action :create
end
end
如果文件尚不存在,两者都应该创建一个文件。 但在 Amazon OpsWorks“设置”阶段的自定义配方的上下文中,第一个解决方案按预期工作。 但是第二个解决方案恰好在我运行配方的每一秒时都会提供“误报”。 "if" 语句返回 false,但文件最后不存在。
所以我想知道在厨师或/和红宝石中是否有任何理由在“if”块内嵌套“模板”资源。 “模板”资源是否运行某种异步?
【问题讨论】:
标签: ruby amazon-web-services chef-infra aws-opsworks