Code Monkey home page Code Monkey logo

chef-solo-repo's Introduction

chef-solo-repo

A fork of chef-repo for chef-solo.

Fork it and add your own cookbooks and server configurations.

Get Started

Hello world

bundle install
bundle exec thor solo:json json/hello-world.json

Or use chef-solo directly

bundle exec chef-solo -c solo.rb -j json/hello-world.json

Test using Vagrant

Cookbooks may modify the system, so test them in virtual machine. Vagrantfile is already provided in this repository, just install VirtualBox and setup a virtual machine 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.

Capistrano

Usually the process to use chef-solo is

  • Define server attributes using a JSON file
  • Upload this repository to server
  • Install cookbooks dependencies
  • Run chef-solo on 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.
  • Run cap deploy to upload repository to server.
  • Capistrano uses bundler to install dependencies
  • Capistrano export server ruby DSL definition file into JSON, and run chef-solo against the JSON file.

The DSL is very simple, and should be placed under directory servers.

# 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]']

All cap remote commands must specify one or multiple server definition files. For example:

  • setup

    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

or simply:

ls servers

Overview

Besides functionaries provided by chef-repo, this repository has some customizations.

Zero Configuration

The repository is ready to go with default configurations and sample cookbook. Chef default configurations use many system paths, such as /etc and /var. Use this repository, you don't need root permission, or go though config files to tweak all the paths.

Thor Tasks

The repository contains thor files for common tasks. These actions ease the daily usage for chef-solo.

Configuration

Files .chef/knife.rb and solo.rb setup some default configurations so chef-solo will not use system location such as /etc and /var.

Key .chef/insecure_client_key.pem is created to pass file test when running knife and chef-solo commands. If you want to use the key to connect chef server, DO generate a key yourself.

Next Steps

Read the README file in each of the subdirectories for more information about what goes in those directories.

chef-solo-repo's People

Contributors

doitian avatar mattray avatar adamhjk avatar v1nc3ntlaw avatar

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.