IaC

Chef Playground

Chef Infra is a powerful infrastructure automation tool that transforms infrastructure into code using Ruby-based recipes and cookbooks..

Get access to the Chef playground with one click

Welcome to the Chef Playground!

Chef Infra — the Ruby-based infrastructure automation platform. Write recipes and cookbooks to define your infrastructure as code, then converge any node to that desired state.

What’s Pre-installed

  • Chef Infra Client (latest via omnitruck) with chef-solo, chef-client, ohai, knife
  • Shell: bash with vim, nano, git, curl, jq, sudo

Quick Start

chef-solo --version
ohai | head -20   # system inventory in JSON
chef-client --version

Common Workflows

# Write and run a recipe
mkdir -p /tmp/chef-demo/cookbooks/myapp/recipes
cat > /tmp/chef-demo/cookbooks/myapp/recipes/default.rb <<'EOF'
file '/tmp/chef-test.txt' do
  content "Hello from Chef!\n"
  mode '0644'
end

execute 'show file' do
  command 'cat /tmp/chef-test.txt'
end
EOF

cat > /tmp/chef-demo/solo.rb <<'EOF'
cookbook_path ['/tmp/chef-demo/cookbooks']
EOF

cat > /tmp/chef-demo/dna.json <<'EOF'
{"run_list":["recipe[myapp]"]}
EOF

chef-solo -c /tmp/chef-demo/solo.rb -j /tmp/chef-demo/dna.json

Advanced Tips

# Generate a cookbook with ChefDK conventions
chef generate cookbook /tmp/mycookbook
ls /tmp/mycookbook/

# Ohai node attributes
ohai | python3 -m json.tool | grep -A2 '"platform"'

# Knife commands (local mode)
knife node list --local-mode
knife cookbook list --local-mode

Session Notes

  • Session lasts 1 hour.
  • Uses chef-solo mode — no Chef Server or internet access required.
  • You have sudo access as codeground for system-level operations.