从源代码安装nginx-1.7.8时,Chef :: Exceptions :: ChecksumMismatch

Wes*_*Wes 8 centos nginx chef-infra vagrant

在运行vagrant up --provision以设置我的开发环境与vagrant 时出现以下错误...

==> default: [2014-12-08T20:33:51+00:00] ERROR: remote_file[http://nginx.org/download/nginx-1.7.8.tar.gz] (nginx::source line 58) had an error: Chef::Exceptions::ChecksumMismatch: Checksum on resource (0510af) does not match checksum on content (12f75e)
Run Code Online (Sandbox Code Playgroud)

我的厨师JSON对nginx有以下内容:

"nginx": {
"version": "1.7.8",
"user": "deploy",
"init_style": "init",
"modules": [
  "http_stub_status_module",
  "http_ssl_module",
  "http_gzip_static_module"
],
"passenger": {
  "version": "4.0.53",
  "gem_binary": "/home/vagrant/.rbenv/shims/gem"
},
"configure_flags": [
  "--add-module=/home/vagrant/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/passenger-3.0.18/ext/nginx"
],
"gzip_types": [
  "text/plain",
  "text/html",
  "text/css",
  "text/xml",
  "text/javascript",
  "application/json",
  "application/x-javascript",
  "application/xml",
  "application/xml+rss"
]}
Run Code Online (Sandbox Code Playgroud)

和Cheffile有以下食谱:

cookbook 'nginx'
Run Code Online (Sandbox Code Playgroud)

如何解决校验和不匹配问题?

Ale*_*eng 14

nginx的食谱需要您编辑checksum使用Nginx的另一个版本时属性.remote_file导致您出错的资源是:

remote_file nginx_url do
  source   nginx_url
  checksum node['nginx']['source']['checksum']
  path     src_filepath
  backup   false
end
Run Code Online (Sandbox Code Playgroud)

您需要更新校验和值.具体node['nginx']['source']['checksum'].

所以在你的JSON中,你会添加这一行:

"source": {"checksum": "insert checksum here" }
Run Code Online (Sandbox Code Playgroud)

编辑:正如评论中指出的,校验和是SHA256.您可以像这样生成文件的校验和:

shasum -a 256 nginx-1.7.8.tar.gz
Run Code Online (Sandbox Code Playgroud)

  • 配方使用[remote_file](https://docs.getchef.com/resource_remote_file.html),需要sha 256校验和,即`shasum -a 256 nginx-1.7.8.tar.gz` (4认同)