Sha256: ef1007d095158662160667650620d8a35e14ab29da83b25575e2b48ada417395

Contents?: true

Size: 730 Bytes

Versions: 1

Compression:

Stored size: 730 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", id, 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.2.0 lib/rake/chef/dsl.rb