Linux command
chef 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
Generate a new cookbook
chef generate cookbook [cookbook_name]
Generate a new recipe
chef generate recipe [cookbook_name] [recipe_name]
Verify cookbook syntax
chef exec cookstyle [cookbook_path]
Run cookbook locally
chef-client --local-mode --runlist "[recipe[cookbook::recipe]]"
Show installed version
chef --version
Install gem into Chef
chef gem install [gem_name]
Run InSpec tests
chef exec inspec exec [test_path]
说明
chef is the command-line interface for Chef Workstation, a configuration management and infrastructure automation platform. It provides tools for developing, testing, and managing cookbooks that define system configurations. Cookbooks contain recipes written in Ruby DSL that describe desired system states. Chef applies these recipes to nodes, ensuring consistent configuration across infrastructure. The workflow includes local development, testing with Test Kitchen, and deployment to Chef Server.
参数
- generate _type_ _name_
- Generate cookbook, recipe, template, or other component.
- exec _command_
- Run command in Chef context with bundled Ruby.
- gem _subcommand_
- Manage Ruby gems in Chef's environment.
- install _policyfile_
- Install cookbooks from Policyfile.
- update _policyfile_
- Update cookbooks in Policyfile.
- export _policyfile_ _path_
- Export policy archive for deployment.
- push _policy_group_ _policyfile_
- Push policy to Chef Server.
- --version
- Show version information.
- --help
- Display help information.
FAQ
What is the chef command used for?
chef is the command-line interface for Chef Workstation, a configuration management and infrastructure automation platform. It provides tools for developing, testing, and managing cookbooks that define system configurations. Cookbooks contain recipes written in Ruby DSL that describe desired system states. Chef applies these recipes to nodes, ensuring consistent configuration across infrastructure. The workflow includes local development, testing with Test Kitchen, and deployment to Chef Server.
How do I run a basic chef example?
Run `chef generate cookbook [cookbook_name]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does generate _type_ _name_ do in chef?
Generate cookbook, recipe, template, or other component.