Sha256: 5162f9ef1d1790feaf387dbf700a8521bbb8dc5b11374bce99252b4153b07804

Contents?: true

Size: 759 Bytes

Versions: 1

Compression:

Stored size: 759 Bytes

Contents

require 'chef'

module Rake
  module DSL

    private

    def recipe(id, &block)
      namespace :chef do
        namespace :recipe do
          desc "Run chef rake task #{id}"
          task id do
            ::Chef::Config[:solo] = true
            @chef_client = ::Chef::Client.new
            @chef_client.run_ohai
            @chef_client.load_node
            @chef_client.build_node
            run_context = ::Chef::RunContext.new(@chef_client.node, {}, @chef_client.events)
            recipe = ::Chef::Recipe.new("(rake-chef cookbook)", "(rake-chef recipe)", run_context)
            recipe.instance_eval(&block)
            runner = ::Chef::Runner.new(run_context)
            runner.converge
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rake-chef-0.1.0 lib/rake/chef/dsl.rb