Class: Chef::Resource::Machine

Inherits:
LWRPBase
  • Object
show all
Defined in:
lib/chef/resource/machine.rb

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Machine

Returns a new instance of Machine.



8
9
10
11
12
13
14
15
16
17
# File 'lib/chef/resource/machine.rb', line 8

def initialize(*args)
  super
  @chef_environment = run_context.cheffish.current_environment
  @chef_server = run_context.cheffish.current_chef_server
  @provisioner = run_context.chef_metal.current_provisioner
  @provisioner_options = run_context.chef_metal.current_provisioner_options
  if run_context.chef_metal.current_machine_batch
    run_context.chef_metal.current_machine_batch.machines << self
  end
end

Instance Method Details

#add_provisioner_options(options) ⇒ Object



91
92
93
# File 'lib/chef/resource/machine.rb', line 91

def add_provisioner_options(options)
  @provisioner_options = Chef::Mixin::DeepMerge.hash_only_merge(@provisioner_options, options)
end

#after_createdObject



19
20
21
22
# File 'lib/chef/resource/machine.rb', line 19

def after_created
  # Notify the provisioner of this machine's creation
  @provisioner.resource_created(self)
end

#file(remote_path, local = nil) ⇒ Object

A single file to upload, in the format REMOTE_PATH, LOCAL_PATH|HASH. This directive may be passed multiple times, and multiple files will be uploaded.

Examples

file ‘/remote/path.txt’, ‘/local/path.txt’ file ‘/remote/path.txt’, { :local_path => ‘/local/path.txt’ } file ‘/remote/path.txt’, { :content => ‘woo’ }



72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/chef/resource/machine.rb', line 72

def file(remote_path, local = nil)
  @files ||= {}
  if remote_path.is_a?(Hash)
    if local
      raise "file(Hash, something) does not make sense.  Either pass a hash, or pass a pair, please."
    end
    remote_path.each_pair do |remote, local|
      @files[remote] = local
    end
  elsif remote_path.is_a?(String)
    if !local
      raise "Must pass both a remote path and a local path to file directive"
    end
    @files[remote_path] = local
  else
    raise "file remote_path must be a String, but is a #{remote_path.class}"
  end
end