Fork it and add your own cookbooks and server configurations.
bundle install bundle exec thor solo:json json/hello-world.json
bundle exec chef-solo -c solo.rb -j json/hello-world.json
Test using Vagrant
bundle exec vagrant up bundle exec vagrant ssh
The last command only prints out SSH login information on Windows, use SSH client such as PuTTY to connect manually.
Usually the process to use
- Define server attributes using a JSON file
- Upload this repository to server
- Install cookbooks dependencies
chef-soloon the server against the JSON file
Capistrano is integrated to automate the process.
- Define server attributes using ruby DSL, the DSL also define user, host, port and ssh options, so capistrano know how to establish the SSH connection.
cap deployto upload repository to server.
- Capistrano uses bundler to install dependencies
- Capistrano export server ruby DSL definition file into JSON, and run
chef-soloagainst the JSON file.
The DSL is very simple, and should be placed under directory
# deploy user for capistrano user 'vagrant' # server IP or domain host '127.0.0.1' # SSH port for capistrano port 2222 # SSH options for capistrano ssh_options(:keys => '~/.vagrant.d/insecure_private_key') # Use node.set, node.default, node.override methods to configure node # attributes. node.set[:name] = 'localhost-sample' # specify run list run_list ['recipe[hello-world]']
cap remote commands must specify one or multiple server definition files. For
cap deploy:setup servers/server_a.rb [servers/server_b.rb ....]
upload repository, run bundle, export JSON and run chef-solo on servers
cap deploy servers/server_a.rb [servers/server_b.rb ....]
Tips: name servers by pattern (using prefix or suffix), and use glob (for shell like bash, zsh, csh) to select servers.
# run on all servers cap deploy servers/* # run on all servers which definition file starting with db- cap deploy servers/db-*.rb
All available servers can be list by
cap -T servers
Besides functionaries provided by chef-repo, this repository has some customizations.
The repository is ready to go with default configurations and sample
cookbook. Chef default configurations use many system paths, such as
/var. Use this repository, you don't need root permission, or go though
config files to tweak all the paths.
The repository contains thor files for common tasks. These actions ease the daily usage for chef-solo.
solo.rb setup some default configurations so
chef-solo will not use system location such as
.chef/insecure_client_key.pem is created to pass file test when running
chef-solo commands. If you want to use the key to connect chef
server, DO generate a key yourself.
Read the README file in each of the subdirectories for more information about what goes in those directories.