Pantry - Configuration management tool for chef-solo
version 0.003
$ mkdir my-project $ cd my-project $ pantry init $ pantry create node foo.example.com $ pantry list nodes $ pantry apply node foo.example.com --recipe nginx $ pantry apply node foo.example.com --default nginx.port=80 $ pantry sync node foo.example.com
pantry is a utility to make it easier to manage a collection of computers with the configuration management tool chef-solo
pantry
Arguments to the pantry command line tool follow a regular structure:
$ pantry VERB [[NOUN] [ARGUMENTS...]]
See the following sections for details and examples by topic.
$ pantry init
This initializes a pantry in the current directory. Currently, it just creates some directories for use storing cookbooks, node data, etc.
$ pantry list nodes
Prints to STDOUT a list of nodes managed within the pantry.
$ pantry create node NAME
Creates a node configuration file for the given NAME. The NAME must be a valid DNS name or IP address.
NAME
$ pantry show node NAME
Prints to STDOUT the JSON data for the given NAME.
$ pantry apply node NAME --recipe nginx --default nginx.port=80
Applies recipes or attributes to the given NAME.
To apply a recipe to the node's run_list, specify --recipe RECIPE or -r RECIPE. May be specified multiple times to apply more than one recipe.
run_list
--recipe RECIPE
-r RECIPE
To apply an attribute to the node, specify --default KEY=VALUE or -d KEY=VALUE. If the KEY has components separated by periods (.), they will be interpreted as subkeys of a multi-level hash. For example:
--default KEY=VALUE
-d KEY=VALUE
KEY
.
$ pantry apply node NAME -d nginx.port=80
will be added to the node's data structure like this:
{ ... # other node data nginx => { port => 80 } }
If the VALUE contains commas, the value will be split and serialized as an array data structure. For example:
VALUE
$ pantry apply node NAME -d nginx.port=80,8080
{ ... # other node data nginx => { port => [80, 8080] } }
Both KEY and VALUE support periods and commas (respectively) to be escaped by a backslash.
$ pantry strip node NAME --recipe nginx --default nginx.port
Strips recipes or attributes from the given NAME.
To strip a recipe to the node's run_list, specify --recipe RECIPE or -r RECIPE. May be specified multiple times to strip more than one recipe.
To strip an attribute from the node, specify --default KEY or -d KEY. The KEY parameter is interpreted and may be escaped just like in apply, above.
--default KEY
-d KEY
apply
$ pantry sync node NAME
Copies cookbooks and configuration data to the NAME node and invokes chef-solo via ssh to start a configuration run.
chef-solo
ssh
$ pantry edit node NAME
Invokes the editor given by the environment variable EDITOR on the configuration file for the name node.
EDITOR
name
The resulting file must be valid JSON in a form acceptable to Chef. Generally, you should use the apply or strip commands instead of editing the node file directly.
strip
pantry relies on OpenSSH for secure communications with managed nodes, but does not manage keys itself. Instead, it expects the user to manage keys using standard OpenSSH configuration and tools.
The user should specify SSH private keys to use in the ssh config file. One approach would be to use the IdentityFile with a host-name wildcard:
IdentityFile
IdentityFile ~/.ssh/identities/id_dsa_%h
This would allow a directory of host-specific identities (which could all be symlinks to a master key). Another alternative might be to create a master key for each environment:
IdentityFile ~/.ssh/id_dsa_dev IdentityFile ~/.ssh/id_dsa_test IdentityFile ~/.ssh/id_dsa_prod
pantry also assumes that the user will unlock keys using ssh-agent. For example, assuming that ssh-agent has not already been invoked by a graphical shell session, it can be started with a subshell of a terminal:
ssh-agent
$ ssh-agent $SHELL
Then private keys can be unlocked in advance of running pantry using ssh-add:
ssh-add
$ ssh-add ~/.ssh/id_dsa_test $ pantry ...
See the documentation for ssh-add for control over how long keys stay unlocked.
Inspiration for this tool came from similar chef-solo management tools. In addition to being implemented in different languages, each approaches the problem in slightly different ways, neither of which fit my priorities. Nevertheless, if you use chef-solo, you might consider them as well:
littlechef (Python)
pocketknife (Ruby)
Please report any bugs or feature requests through the issue tracker at https://github.com/dagolden/pantry/issues. You will be notified automatically of any progress on your issue.
This is open source software. The code repository is available for public review and contribution under the terms of the license.
https://github.com/dagolden/pantry
git clone https://github.com/dagolden/pantry.git
David Golden <dagolden@cpan.org>
This software is Copyright (c) 2011 by David Golden.
This is free software, licensed under:
The Apache License, Version 2.0, January 2004
To install Pantry, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Pantry
CPAN shell
perl -MCPAN -e shell install Pantry
For more information on module installation, please visit the detailed CPAN module installation guide.