Find the Best Cosmetic Hospitals

Explore trusted cosmetic hospitals and make a confident choice for your transformation.

“Invest in yourself — your confidence is always worth it.”

Explore Cosmetic Hospitals

Start your journey today — compare options in one place.

Chef Command-Line Reference: Essential chef-solo, chef-client, and Knife Workflows

Originally published on 2015-09-20; fully revised and updated.

This page is a practical Chef CLI quick reference for DevOps engineers who need common commands in one place. It covers local recipe execution, cookbook generation, cookbook distribution, node bootstrap, and routine Knife operations, with notes where version differences can affect syntax.

Chef command families at a glance

Tool/command familyPrimary purposeTypical use case
chef-soloRun a recipe without Chef ServerLocal or standalone execution from a solo.rb config
chef-applyApply a single recipe file directlyQuick local tests on one machine
chef-client –local-modeConverge locally using a run listTest cookbook behavior without full server workflow
knife cookbook *Create/download/upload cookbooksManage cookbook lifecycle between local repo and server
knife bootstrapRegister and provision a nodeInitial onboarding of a target machine
knife node *Inspect and edit node metadata/run listsOperational node management
knife sshRun remote commands on selected nodesTrigger chef-client runs across nodes

Generate cookbook structure and files

Use these commands to scaffold a new cookbook and add template files. The examples below preserve the command intent from the original post.

chef generate cookbook learn_chef_httpd
knife cookbook create smartmontools -r md
chef generate template learn_chef_httpd index.htmlCode language: CSS (css)

Run recipes and cookbooks locally

These commands are commonly used during development and troubleshooting before deploying to managed nodes.

chef-solo -c /opt/chef/repo/config/solo.rb -o 'my_cookbook::recipe'
chef-apply hello.rb
sudo chef-client --local-mode --runlist 'recipe[learn_chef_httpd]'Code language: JavaScript (javascript)

Download and upload cookbooks

Use Knife cookbook commands to fetch cookbook artifacts and publish local cookbooks to Chef Server.

knife cookbook site download learn_chef_httpd
knife cookbook site install learn_chef_httpd
knife cookbook upload learn_chef_httpd
knife cookbook upload -a

Bootstrap nodes and manage run lists with Knife

The following examples show common node onboarding and day-2 operations. Replace hostnames, usernames, and credentials with your environment values.

knife bootstrap ADDRESS --ssh-user USER --ssh-password 'PASSWORD' --sudo --use-sudo-password --node-name node1 --run-list 'recipe[learn_chef_apache2]'
knife bootstrap uvo1t75faaktzc532w6.vm.cld.sr -x root -P Br356YS0iy --sudo --node-name firefox
knife bootstrap 123.45.6.789 -x username -P password --sudoCode language: JavaScript (javascript)
knife node list
knife node show node1
knife node edit name_of_node
knife node run_list add C2445575914.domain 'recipe[hptrain]'
knife node run_list set test-node 'recipe[iptables]'Code language: PHP (php)
knife ssh ADDRESS 'sudo chef-client' --manual-list --ssh-user USER --ssh-password 'PASSWORD'
ssh username@ipaddress -i mycredentials.pem sudo chef-clientCode language: PHP (php)

Typical Chef workflow

flowchart LR
    A[Generate cookbook] --> B[Add recipe and template]
    B --> C[Run local converge]
    C --> D[Download dependencies]
    D --> E[Upload cookbook]
    E --> F[Bootstrap node]
    F --> G[Run chef-client on node]
    G --> H[Validate node state]

Reference link preserved from the original post

The original page included a YouTube API-key troubleshooting reference: https://www.youtube.com/watch?v=ZCfrNvu6nMc.

Best practices and common pitfalls

  • Prefer SSH keys over plaintext passwords in bootstrap and remote execution commands.
  • Run local convergence first (chef-apply, chef-solo, or local-mode) before server upload.
  • Keep run lists explicit and review node state after every run-list change.
  • Validate command flags against your installed Chef Infra/Knife version, especially on older tutorials.

Find Trusted Cardiac Hospitals

Compare heart hospitals by city and services — all in one place.

Explore Hospitals
I'm Rajesh Kumar, a DevOps, SRE, DevSecOps, Cloud, and Platform Engineering expert passionate about sharing practical knowledge, real-world experiences, and industry best practices. I have worked at Cotocus and regularly write about technology, travel, investing, health, product reviews, and digital marketing through my various platforms. I publish technical articles at DevOps School, travel stories at Holiday Landmark, stock market insights at Stocks Mantra, health and fitness guidance at My Medic Plus, product reviews at TrueReviewNow, and SEO and digital marketing strategies at Wizbrand.

Related Posts

How to Install ChefDK on RHEL, Ubuntu, macOS, and Windows (Legacy-Friendly Guide)

Learn a practical, cross-platform process to install ChefDK and verify it correctly on RHEL/CentOS, Ubuntu, macOS, and Windows. This guide also helps you decide when ChefDK is still appropriate versus Chef Workstation.

Read More

Foodcritic for Chef Cookbooks: Practical Linting and Jenkins CI for Legacy Pipelines

Foodcritic helps you statically lint Chef cookbooks for style, correctness, and common anti-patterns before convergence fails in production. This guide shows how to run it locally, wire it into Jenkins, and enforce fail policies that teams will actually use.

Read More

Automating Chef Cookbook README Files with Knife and Community Plugins

Reusable Chef cookbooks often outgrow their documentation. This guide shows how to bootstrap README files with Knife, compare plugin-based generation options, and keep docs in sync as cookbooks evolve.

Read More

What is Chef and use cases of Chef?

What is Chef? Chef is a powerful configuration management and automation tool that allows organizations to manage and automate the deployment, configuration, and maintenance of infrastructure. It…

Read More

What is Chef Compliance and use cases of Chef Compliance?

What is Chef Compliance? Chef Compliance is a component of Chef, an automation platform used for configuration management, application deployment, and infrastructure as code (IaC). Chef Compliance…

Read More
Subscribe
Notify of
guest
0 Comments
Newest
Oldest Most Voted
0
Would love your thoughts, please comment.x
()
x