You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

指定Chef Cookbook版本运行问题:nginx cookbook 1.7.2无法执行

Fixing Chef Cookbook Version Specification Not Taking Effect

Hey there, the issue you're hitting is that the recipe[nginx::default@1.7.2] syntax you’re using in your run_list is deprecated in modern Chef versions—this was a feature from older Chef Client releases (like Chef 12 and earlier), which is why it’s not working with your newly installed latest Chef environment.

Here are the most reliable ways to lock your nginx cookbook to version 1.7.2, ordered by recommendation:

1. Use Berkshelf to Pin the Version (Most Common Workflow)

If you’re using Berkshelf for cookbook dependency management, add this line to your Berksfile:

cookbook 'nginx', '1.7.2'

Run berks install to pull down the exact version, then berks upload if you’re using a Chef Server. For local Kitchen testing, Berkshelf will automatically handle pulling the correct version when you run kitchen converge.

2. Define the Version in a Policyfile

If you’re using Chef Policyfiles for configuration management, specify the version in your Policyfile.rb:

name 'your_policy_name'
default_source :supermarket
run_list 'nginx::default'
cookbook 'nginx', '1.7.2'

Run chef install to generate the Policyfile.lock.json, which Kitchen will use to resolve the exact cookbook version during convergence.

3. Point to a Local Cookbook Directory (For Offline/Local Development)

If you’ve already downloaded the nginx 1.7.2 cookbook to your machine, update your .kitchen.yml to include the path to this specific version:

cookbook_path:
  - './cookbooks/nginx-1.7.2'
  - './other-cookbooks'

Kitchen will prioritize loading the cookbook from the specified local path instead of pulling the latest from Supermarket or Chef Server.

Quick Note

The recipe[cookbook::recipe@version] syntax you remember was phased out years ago in favor of more robust dependency management tools like Berkshelf and Policyfiles. These tools make it easier to track and enforce exact cookbook versions across your infrastructure, avoiding unexpected updates.

内容的提问来源于stack exchange,提问作者user9753902

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.27 03:56:25