如何为 Chef 本地模式指定 chef_environment (chef-client -z)

How to specify chef_environment for chef local mode (chef-client -z)

我已将 Chef 文件从我的 Chef 服务器复制到本地客户端节点,在 ~/.chef 下,我在 ~/.chef/environments 下拥有所有环境,例如development.rbproduction.rb

当我从 ~/.chef/ 下 运行 chef-client -z -E development -r 'recipe[cookbook_foo::recipe_bar]' 我得到这个错误:

================================================================================
Error expanding the run_list:
================================================================================

Unexpected API Request Failure:
-------------------------------
Object not found: http://localhost:8889/environments/development

如果我 运行 没有 -E development 的命令一切正常。但是,我需要传递环境名称,因为该厨师食谱中使用了 #{node.chef_environment} 变量。 Google 没有给我提供关于这个问题的答案:/

我正在使用 Chef 客户端 11.16.4

有什么想法吗?

不幸的是,零号厨师不理解 .rb DSL 文件。您需要将您的环境文件转换为 .json 才能与 Chef Zero 一起使用。