仅在厨师中更新了我的jar文件时,如何解压缩文件?

问题描述

在Chef中,我想将tarball解压缩到特定目录,但前提是该特定目录中的“ new.jar”文件更改了其内容名称

我遇到的问题是我的节点中有一个现有的“ new.jar”文件,但是当我更新食谱的“ files”目录中的“ new.jar”文件时,请做我的厨师运行时,jar文件不会得到更新,因为尽管名称文件大小相同,尽管它是较新的版本。我该如何解决这个问题?

execute 'Untar' do
  command "tar zxvf #{sweeper_install_dir}/test.tar.gz -C #{dir}"
  not_if { ::File.exist?("#{dir}/new.jar") }
end

解决方法

看起来像是您对鸡肉和鸡蛋的状况感到震惊。因此,我了解您的问题是正确的,您已经更新了 test.tar.gz 的版本,并且由于厨师服务器中已经存在 new.jar 而未更新厨师版。服务器。

解决方案是您必须做些没什么不同的事情

  1. 首先,您必须下载 test.tar.gz 文件(如果是新文件)。
  2. 如果下载了新文件,则解压缩到目标位置。

就这样

Possible Unhandled Promise Rejection (id: 0):
Error: Request failed with status code 400

55: Error: Request failed with status code 400 at createError (http://192.168.1.84:8081/index.bundle?platform=ios&dev=true&minify=false:200434:17) at settle (http://192.168.1.84:8081/index.bundle?platform=ios&dev=true&minify=false:200424:14) at EventTarget.handleLoad (http://192.168.1.84:8081/index.bundle?platform=ios&dev=true&minify=false:200322:9) at EventTarget.dispatchEvent (http://192.168.1.84:8081/index.bundle?platform=ios&dev=true&minify=false:34182:27) at EventTarget.setReadyState (http://192.168.1.84:8081/index.bundle?platform=ios&dev=true&minify=false:33251:14) at EventTarget.__didCompleteResponse (http://192.168.1.84:8081/index.bundle?platform=ios&dev=true&minify=false:33093:16) at http://192.168.1.84:8081/index.bundle?platform=ios&dev=true&minify=false:33203:47 at RCTDeviceEventEmitter.emit (http://192.168.1.84:8081/index.bundle?platform=ios&dev=true&minify=false:7046:37) at MessageQueue.__callFunction (http://192.168.1.84:8081/index.bundle?platform=ios&dev=true&minify=false:2789:44) at http://192.168.1.84:8081/index.bundle?platform=ios&dev=true&minify=false:2511:17
config: {url: "/",method: "get",headers: {…},baseURL: "https://netsocial-129849.uc.r.appspot.com/api/v1/posts",transformRequest: Array(1),…}
isAxiosError: true
request: EventTarget {UNSENT: 0,OPENED: 1,HEADERS_RECEIVED: 2,LOADING: 3,DONE: 4,…}
response: {data: "Invalid token.",status: 400,statusText: undefined,config: {…},…}
toJSON: ƒ ()
message: "Request failed with status code 400"
stack: "Error: Request failed with status code 400↵    at createError (http://192.168.1.84:8081/index.bundle?platform=ios&dev=true&minify=false:200434:17)↵    at settle (http://192.168.1.84:8081/index.bundle?platform=ios&dev=true&minify=false:200424:14)↵    at EventTarget.handleLoad (http://192.168.1.84:8081/index.bundle?platform=ios&dev=true&minify=false:200322:9)↵    at EventTarget.dispatchEvent (http://192.168.1.84:8081/index.bundle?platform=ios&dev=true&minify=false:34182:27)↵    at EventTarget.setReadyState (http://192.168.1.84:8081/index.bundle?platform=ios&dev=true&minify=false:33251:14)↵    at EventTarget.__didCompleteResponse (http://192.168.1.84:8081/index.bundle?platform=ios&dev=true&minify=false:33093:16)↵    at http://192.168.1.84:8081/index.bundle?platform=ios&dev=true&minify=false:33203:47↵    at RCTDeviceEventEmitter.emit (http://192.168.1.84:8081/index.bundle?platform=ios&dev=true&minify=false:7046:37)↵    at MessageQueue.__callFunction (http://192.168.1.84:8081/index.bundle?platform=ios&dev=true&minify=false:2789:44)↵    at http://192.168.1.84:8081/index.bundle?platform=ios&dev=true&minify=false:2511:17"
__proto__: Object