0.01
No commit activity in last 3 years
No release in over 3 years
Discover hosts using chef search for blender
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

>= 12.1.1
 Project Readme

Blender-Chef

A chef based host discovery plugin for Blender

Installation

  gem install blender-chef

Usage

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: 'https://foo.bar.com', 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: 'https://example.com')
members(search(:chef, 'ec2_local_ipv4:10.13.12.11'))
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 https://opscode-omnibus-packages.s3.amazonaws.com/ubuntu/13.04/x86_64/chef_12.0.3-1_amd64.deb'
    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]
    end

    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 foo.bar.com -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

License

Apache 2

Contributing

  1. Fork it ( https://github.com/PagerDuty/blender-chef/fork )
  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