Skip to content


Folders and files

Last commit message
Last commit date

Latest commit



52 Commits

Repository files navigation


A chef based host discovery plugin for Blender


  gem install blender-chef


With blender-chef, host list for blender jobs can be automatically fetched from Chef server. Following is an example of dynamically obtaining all servers with db role, and enlisting their iptables rule.

require 'blender/chef'
config(:chef, chef_sever_url: '', node_name: 'admin', client_key: 'admin.pem')
members(search(:chef, 'roles:db'))
ssh_task 'sudo iptables -L'

Aany valid chef search can be used. You can pass the node_name, chef_server_url and client_key for chef server config.

config(:chef, node_name: 'admin', client_key: 'admin.pem', chef_server_url: '')
members(search(:chef, 'ec2_local_ipv4:'))
ssh_task 'sudo iptables -L'

Alternatively, you can also use a config file lile client.rb or knife.rb

config(:chef, config_file: '/etc/chef/client.rb')
members(search(:chef, 'roles:db'))

By default blender-chef will pass the FQDN of chef nodes as member list, in this case as ssh targets. This can be customized by passing the attribute option.

config(:chef, node_name: 'admin', client_key: 'admin.pem')
members(search(:chef, 'roles:db', attribute: 'ec2_public_ipv4'))

Knife integration

Blender-chef comes with a knife plugin that allows job or chef recipe or node bootstrapping from command line interface.

  • Blender-mode, for running raw blender jobs Given the following job present in file jobs/upgrade_chef.rb

    ssh_task 'sudo apt-get remove chef --purge'
    ssh_task 'sudo apt-get remove chef --purge'
    ssh_task 'wget -c'
    ssh_task 'sudo dpkg -i chef_12.0.3-1_amd64.deb'
    ssh_task 'sudo chef-client'

    It can be executed against all chef nodes having db role as:

    knife blend --search 'roles:db' jobs/upgrade_chef.rb

    this is equivalent to

    knife blend --mode blender --search 'roles:db' jobs/upgrade_chef.rb

    as blender mode is the default mode.

  • Recipe mode, for running one-off chef recipes against remote nodes using blender Given the following chef recipe present ina local file recipes/nginx.rb

    package 'nginx'
    service 'nginx' do
      action [:start, :enable]

    It can be executed against all chef nodes having web role as:

    knife blend --mode recipe --search 'roles:web' recipes/nginx.rb

    In recipe mode blender will treat the input file(s) as chef recipe and build necessary scp and ssh tasks to upload the recipe, execute it and remove the uploaded recipe.

  • Berkshelf mode, for bootstrapping server with chef solo. In this mode blender-chef will assume the specifid file is a Berksfile, and use it to vendor cookbooks, then upload it to the remote server using scp, and finally run chef in localmode against the vendored cookbook directory. In berkshelf mode run list is specified via --run-list option.

    knife blend Berksfile --mode berkshelf -h -i id_rsa --run-list recipe[nginx]

    Note: You have to install berkshelf explicitly (vie bundler or using raw gem commands).

    Additional options are provided to control strategy, ssh credentials etc.

Supported ruby versions

Blender-chef uses Chef 12 (for partial search). For chef 11, use 0.0.1 version of blender-chef.

Blender-chef currently support the following MRI versions:

  • Ruby 2.1.0
  • Ruby 2.1.2


Apache 2


  1. Fork it ( )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request