Chef 使用 "cookbook_file" 作为 "windows_zipfile" 资源的来源
Chef use "cookbook_file" as source for "windows_zipfile" resource
我正在尝试使用 "windows" 食谱中的 windows_zipfile 资源,但我需要解压缩的文件位于食谱中的 files/default 我是 运行.
通常我会使用 "cookbook_file" 资源访问此文件,如何使用 windows_zipfile 资源访问它?
我试过:
windows_zipfile 'c:\test_app' do
source 'files/default/test_app.zip'
action :unzip
end
得到了"File files\default\test_zpp.zip not found"
您需要在本地创建文件,然后 运行 您的 windows_zipfile 资源。您正在尝试在您的存储库中解压缩文件,而不是在您的节点上。这里的 source
是本地文件系统上的文件。
cookbook_file 'c:/testapp.zip' do
source 'files/default/test_app.zip'
end
windows_zipfile 'c:/test_app' do
source 'c:/testapp.zip'
action :unzip
not_if {::File.exists?('c:/test_app')}
end
^此外,请确保包含一个 not_if
守卫以保护幂等性(这样每个 Chef 运行 都不会尝试解压缩)。
windows 食谱中提到了这一点。
我正在尝试使用 "windows" 食谱中的 windows_zipfile 资源,但我需要解压缩的文件位于食谱中的 files/default 我是 运行.
通常我会使用 "cookbook_file" 资源访问此文件,如何使用 windows_zipfile 资源访问它?
我试过:
windows_zipfile 'c:\test_app' do
source 'files/default/test_app.zip'
action :unzip
end
得到了"File files\default\test_zpp.zip not found"
您需要在本地创建文件,然后 运行 您的 windows_zipfile 资源。您正在尝试在您的存储库中解压缩文件,而不是在您的节点上。这里的 source
是本地文件系统上的文件。
cookbook_file 'c:/testapp.zip' do
source 'files/default/test_app.zip'
end
windows_zipfile 'c:/test_app' do
source 'c:/testapp.zip'
action :unzip
not_if {::File.exists?('c:/test_app')}
end
^此外,请确保包含一个 not_if
守卫以保护幂等性(这样每个 Chef 运行 都不会尝试解压缩)。
windows 食谱中提到了这一点。