我正在为应用程序部署编写一些厨师食谱。 我提取代码然后编辑它。它看起来像:
bash 'admin-init' do
user "root"
code <<-EOH
<here I extract the code>
EOH
end
execute 'configure' do
file = Chef::Util::FileEdit.new(node["code_dir"] + "websaas/settings.py")
file.search_file_replace("'HOST': '*'", "'HOST': '" + node["db_host"] + "'")
file.write_file
end
我的问题是在编译期间,settings.py还没有,所以我得到:
ArgumentError
-------------
File doesn't exist
在厨师编译期间我该如何解决?
谢谢Arshavski Alexander
答案 0 :(得分:0)
您需要使用ruby_block
资源,而不是execute
资源。你的执行资源甚至没有定义命令,因此没有任何效果。
ruby_block 'configure' do
block do
file = Chef::Util::FileEdit.new(node["code_dir"] + "websaas/settings.py")
file.search_file_replace("'HOST': '*'", "'HOST': '" + node["db_host"] + "'")
file.write_file
end
end