Giter VIP home page Giter VIP logo

chef-solo-helper's Introduction

Chef scripts

This repository contains scripts for running chef in a serverless environment with one or more git repositories containing the chef configuration.

Installation instructions

Git key

You may need to install SSH keys to the system; if using a bootstrap script, it may handle this for you.

Keys are typically stored under /var/chef-solo, eg chef.key . It must be readable only by root.

You can also specify keys to use for specific repos using the checkout list.

Repositories

In general, there are N+1 repositories for each chef installation:

  • Scripts to run chef (the + 1). This is always present, and is checked out into /var/chef-solo/scripts .
  • One or more checkouts, building up a set of cookbooks, roles, and node configuration data. The list of checkouts is determined dynamically by executing a command in the config.sh file. Each checkout is then delivered into the /var/chef-solo/checkouts directory. Each may have a cookbooks, nodes, roles, handlers, and data_bags directory.

Chef scripts repository

This step is normally performed by a bootstrapping script.

Check out the scripts repository to /var/chef-solo/scripts/:

sudo mkdir /var/chef-solo
cd
git clone [email protected]:~internal/chef/scripts
sudo mv scripts /var/chef-solo/scripts

List of Additional Checkouts/Repositories

run_chef.sh will fetch a list of additional checkouts. The list should be in CSV format with no spaces between fields. Example:

git,[email protected]:~internal/chef/systems,omniti-internal-systems,master,chef.key git,[email protected]:~internal/chef/common,omniti-internal-common,multi-repo,chef.key git,[email protected]:myproject/support/chef,myproject-chef,master,AGENT git,https://github.com/opscode-cookbooks/php.git,opscode-php/cookbooks/php,master,NONE

The fields are: VCS,repo address, directory name, branch, credentials

  • VCS may be either 'git' or 'svn'.
  • repo address is the identifier of the repository from which to obtain the checkout.
  • directory name is the path under /var/chef-solo/checkouts to clone/checkout into. It may contain slashes.
  • branch is the name of the git branch. Leave blank for svn (use repo address for svn branching)
  • credentials is the method to authenticate to the repo server. NONE means use no authentication. AGENT means to rely on a running ssh-agent to provide credentials. All other values are taken to specify the location of a SSH private key, relative to /var/chef-solo, that should be used with a GIT_SSH wrapper.

On each run, the checkout list will be re-fetched, and each checkout will be cloned/checked-out (if absent) or pulled/updated (if present). No facility exists for deleting a checkout.

Cross-Linking Roles, Nodes, Etc

Chef can use multiple cookbook directories, but only one roles, databags, and nodes directory. To overcome this, run-chef maintains a 'combined' directory, with a 'combined/roles' directory containing links to EVERY role in the various checkouts.

Combined objects are linked in the order specified in the checkout list file. In the event of naming collisions, the LATER entry wins.

Config File

This step is normally performed by a bootstrapping script, which will usually copy in or create a pre-existing config.sh

In /var/chef-solo/scripts/config.sh , add any settings you'd like to override.

FETCH_CHECKOUT_LIST_COMMAND

Default: "cat /var/chef-solo/checkout-list"

This command will be used to fetch the checkout list. One simple example might be:

FETCH_CHECKOUT_LIST_COMMAND="cat /var/chef-solo/checkout-list" FETCH_CHECKOUT_LIST_COMMAND="wget -O - -q http://trac.omniti.net/checkout-lists/myproject "

If the environment was bootstrapped, the bootstrapper may have delivered the checkout-list file.

INTERVAL

Default: 1800 If you run_chef.sh as a daemon (without the -o), number of seconds to sleep between runs.

CHEF_ROOT

Default: "/var/chef-solo" Location on the filesystem for the various bits of this installation.

LOGFILE

Default: /var/log/chef/solo.log Location of the logfile.

SPLAY

Default: 120 When running in daemon mode, wait a random number of seconds up to this value, to offset the run interval.

Running chef

The run-chef.sh script is used to run chef. It can:

  • update from git before running chef (optional)
  • run once, or multiple times
  • when running multiple times, apply a random delay at the beginning

Testing

Run chef once, without updating from git first:

sudo ./run_chef.sh -o -n

Run chef once, updating from git first:

sudo ./run_chef.sh -o

Run chef once, don't update from git, and print out lots of debug information:

sudo ./run_chef.sh -ondv

Running as a daemon

By default, run_chef.sh will run continuously, running chef at regular intervals.

There is an smf manifest in the resources directory, it looks in /var/chef-solo/config for run_chef.sh:

svccfg import resources/chef-manifest.xml
svcadm enable chef

Changes from 'full' chef

  • cookbooks, roles and databags work identically to full chef, only you don't upload them with the knife command (there isn't a knife command)
  • searching isn't available (there's no server to search)
  • node configuration is kept in json files in the nodes/ directory and not on the chef server. These files contain the run list for each host.

chef-solo-helper's People

Contributors

clintoncwolfe avatar haarg avatar mamurphy avatar mivok avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

chef-solo-helper's Issues

support for loading environments from file

Just dropping a note here in case anyone else will find it useful.

We needed support for loading environment overrides from a file (migrating off chef-server, lots of existing cookbooks, etc).

This patch, along with chef 11.4.0 and chef/chef#649 got the job done for us.

+THINGS_TO_COMBINE="nodes roles environments data_bags handlers"

 CHEF_ROOT="/var/chef-solo"

diff --git a/solo.rb b/solo.rb
index ab23ad1..2f09ced 100644
--- a/solo.rb
+++ b/solo.rb
@@ -4,6 +4,7 @@ file_cache_path "/var/chef-solo/cache"
 # These are created by run-chef.sh, with symlinks
 role_path "/var/chef-solo/combined/roles"
 data_bag_path "/var/chef-solo/combined/data_bags"
+environment_path "/var/chef-solo/combined/environments"

 # The checkouts each may contain a cookbooks directory.  run-chef.sh will 
 # write a .cookbook-order file, and we should respect it.
@@ -21,3 +22,5 @@ cookbook_path cookbook_paths
 # Note that we also have handler under the combined/handlers area
 Dir.glob('/var/chef-solo/scripts/handlers/*.rb') { |f| require f }
 Dir.glob('/var/chef-solo/scripts/handlers/site/*.rb') { |f| require f }
+
+environment ENV['CHEF_ENVIRONMENT'] || "_default"

Also thanks to omniti. chef-solo-helper is very useful!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.