Sha256: f3e4156c55437f7224c893b97fe26395a14921dc0e6d92ddcc4f5284cb0b28a9

Contents?: true

Size: 722 Bytes

Versions: 1

Compression:

Stored size: 722 Bytes

Contents

require 'singleton'
require 'forwardable'
require 'ridley'
require 'silver_spurs/chef_exceptions'

module SilverSpurs
  class ChefInterface

    def initialize(options)
      @chef_config = options
    end

    def chef_run(node_name, run_list = [])
      node = find_node node_name
      if run_list.size > 0
        command = "sudo chef-client -o '#{run_list.join(',')}'"
        ridley.node.execute_command node.public_hostname, command
      else
        node.chef_run
      end
    end

    private

    def ridley
      @ridley ||= Ridley.new(@chef_config)
    end

    def find_node(node_name)
      node = ridley.node.find(node_name)
      raise NodeNotFoundException.new unless node
      node
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
silver_spurs-2.0.0.rc1 lib/silver_spurs/chef_interface.rb