0
저는 현재 Chef 배포 중에 속성 파일을 처리하기위한 간단한 스크립트로 작업하고 있습니다. 내가 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가 실행되고 가드와 상관없이.