Skip to content

Instantly share code, notes, and snippets.

@stevendanna
Last active November 30, 2022 07:02
Show Gist options
  • Save stevendanna/5552324 to your computer and use it in GitHub Desktop.
Save stevendanna/5552324 to your computer and use it in GitHub Desktop.
A small chef-solo example

An example cookbook directory

sdanna@gaius ~/tmp/example > tree
.
├── cookbooks
│   └── foobar
│       ├── CHANGELOG.md
│       ├── README.md
│       ├── attributes
│       ├── definitions
│       ├── files
│       │   └── default
│       ├── libraries
│       ├── metadata.rb
│       ├── providers
│       ├── recipes
│       │   └── default.rb
│       ├── resources
│       └── templates
│           └── default
└── solo.rb

12 directories, 5 files

My minimal solo.rb

sdanna@gaius ~/tmp/example > cat solo.rb
cookbook_path '/Users/sdanna/tmp/example/cookbooks'

My test recipe

sdanna@gaius ~/tmp/example > cat cookbooks/foobar/recipes/default.rb
#
# Cookbook Name:: foobar
# Recipe:: default
#
# Copyright 2013, YOUR_COMPANY_NAME
#
# All rights reserved - Do Not Redistribute
#

log "I'm Running Chef"

A chef run

sdanna@gaius ~/tmp/example > sudo chef-solo -c solo.rb -o 'recipe[foobar]'
Starting Chef Client, version 11.4.4
[2013-05-09T21:10:11-07:00] WARN: Run List override has been provided.
[2013-05-09T21:10:11-07:00] WARN: Original Run List: []
[2013-05-09T21:10:11-07:00] WARN: Overridden Run List: [recipe[foobar]]
Compiling Cookbooks...
Converging 1 resources
Recipe: foobar::default
  * log[I'm Running Chef] action write

Chef Client finished, 1 resources updated
@okdas
Copy link

okdas commented May 3, 2018

@shiva9142 It's up to you how to ship the code. I would consider using dedicated private SSH key for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment