Search code examples
chef-infrachef-zero

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


I have copied chef files from my chef server to a local client node, under ~/.chef, i have all environments under ~/.chef/environments, e.g. development.rb, production.rb, etc.

When i run chef-client -z -E development -r 'recipe[cookbook_foo::recipe_bar]' from under ~/.chef/ i get this error:

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

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

If i run the command without -E development everything works fine. However, i need to pass the environment name, because #{node.chef_environment} variable is used in that chef recipe. Google didn't provide me with an answer on this one :/

I'm using chef client 11.16.4

Any ideas?


Solution

  • Unfortunately Chef Zero doesn't understand the .rb DSL files. You'll need to convert your environment files to .json to use them with Chef Zero.