web_app_jar = Chef::Config[:file_cache_path] + 'http://1.1-SNAPSHOT/20170803.130333-19.jar
'
spring_boot_web_app 'app_0' do
jar_remote_path web_app_jar
end
spring_boot_web_app 'app_1' do
jar_remote_path web_app_jar
user 'another_bootapp_user'
group 'another_bootapp_group'
port 8091
wait_for_http true
wait_for_http_retries 30
wait_for_http_retry_delay 2
end
spring_boot_web_app 'app_0' do
action :uninstall
end
spring_boot_web_app 'no-such-app' do
action :uninstall
end
错误
================================================================================
Error executing action `install` on resource 'spring_boot_web_app[app_0]'
================================================================================
Chef::Exceptions::InvalidRemoteFileURI
--------------------------------------
"/var/chef/cachehttp://http://1.1-SNAPSHOT/20170803.130333-19.jar\n" is not a valid `source` parameter for remote_file. `source` must be an absolute URI or an array of URIs.
Cookbook Trace:
---------------
/var/chef/cache/cookbooks/spring-boot/providers/web_app.rb:28:in `block (2 levels) in class_from_file'
/var/chef/cache/cookbooks/spring-boot/providers/web_app.rb:27:in `block in class_from_file'
Resource Declaration:
---------------------
# In /var/chef/cache/cookbooks/spring-boot/recipes/example.rb
4: spring_boot_web_app 'app_0' do
5: jar_remote_path web_app_jar
6: end
7:
Compiled Resource:
------------------
# Declared in /var/chef/cache/cookbooks/spring-boot/recipes/example.rb:4:in `from_file'
spring_boot_web_app("app_0") do
action [:install]
retries 0
retry_delay 2
default_guard_interpreter :default
declared_type :spring_boot_web_app
cookbook_name "spring-boot"
recipe_name "example"
jar_remote_path "/var/chef/cachehttp://http://1.1-SNAPSHOT/20170803.130333-19.jar\n"
user "bootapp"
group "bootapp"
end
System Info:
------------
chef_version=12.21.3
platform=redhat
platform_version=7.2
ruby=ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-linux]
program_name=chef-client worker: ppid=20573;start=09:16:14;
executable=/opt/chef/bin/chef-client
答案 0 :(得分:0)
您不能将URI用作Unix文件路径,特别是在Unix路径中不允许使用//
。通常的解决方法是这样的:web_app_jar = "#{Chef::Config[:file_cache_path]}/#{uri.split(%r{/}).last}"
,即只使用最后一个文件组件。