0
私は現在、シェフのデプロイ時にプロパティファイルを処理するための簡単なスクリプトを作成しています。私はchef-apply script.rb
ソースファイルが存在する場合、ファイルをコピーするシェフレシピを書くにはどうすればいいですか? only_ifガードが動作しない
class_path = '/var/lib/tomcat/webapps/ROOT/WEB-INF/classes'
file '/home/corp/working/corp.properties' do
owner 'root'
group 'root'
mode 0644
p File.exist?("#{class_path}")
content File.open("#{class_path}/corp.properties").read
action :create_if_missing
only_if { File.exist?("#{class_path}/corp.properties") }
end
で、次のコードを実行しています。しかし、それは誤り
false
[2017-12-20T11:37:40-05:00] FATAL: Stacktrace dumped to /home/corp/.chef/cache/chef-stacktrace.out
[2017-12-20T11:37:40-05:00] FATAL: Stacktrace dumped to /home/corp/.chef/cache/chef-stacktrace.out
[2017-12-20T11:37:40-05:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
[2017-12-20T11:37:40-05:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
[2017-12-20T11:37:40-05:00] FATAL: Errno::ENOENT: No such file or directory @ rb_sysopen - /var/lib/tomcat/webapps/ROOT/WEB-INF/classes/corp.properties
[2017-12-20T11:37:40-05:00] FATAL: Errno::ENOENT: No such file or directory @ rb_sysopen - /var/lib/tomcat/webapps/ROOT/WEB-INF/classes/corp.properties
あなたが見ることができるようにして走る、File.exist?
呼び出しはfalseを返しているにもかかわらず、File.openが実行されていますガードにかかわらず。