Class: Chef::Resource::Machine
- Inherits:
-
LWRPBase
- Object
- LWRPBase
- Chef::Resource::Machine
- Defined in:
- lib/chef/resource/machine.rb
Direct Known Subclasses
Instance Method Summary collapse
- #add_machine_options(options) ⇒ Object
-
#file(remote_path, local = nil) ⇒ Object
A single file to upload, in the format REMOTE_PATH, LOCAL_PATH|HASH.
-
#initialize(*args) ⇒ Machine
constructor
A new instance of Machine.
-
#load_prior_resource(*args) ⇒ Object
This is here because provisioning users will probably want to do things like: machine “foo” action :destroy end.
Constructor Details
#initialize(*args) ⇒ Machine
Returns a new instance of Machine.
12 13 14 15 16 17 18 |
# File 'lib/chef/resource/machine.rb', line 12 def initialize(*args) super @chef_environment = run_context.cheffish.current_environment @chef_server = run_context.cheffish.current_chef_server @driver = run_context.chef_provisioning.current_driver @machine_options = run_context.chef_provisioning. end |
Instance Method Details
#add_machine_options(options) ⇒ Object
100 101 102 |
# File 'lib/chef/resource/machine.rb', line 100 def () @machine_options = Cheffish::MergedConfig.new(, @machine_options) 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’ }
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/chef/resource/machine.rb', line 81 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 |
#load_prior_resource(*args) ⇒ Object
This is here because provisioning users will probably want to do things like: machine “foo”
action :destroy
end
Without this, the first resource’s machine options will obliterate the second resource’s machine options, and then unexpected (and undesired) things happen.
118 119 120 |
# File 'lib/chef/resource/machine.rb', line 118 def load_prior_resource(*args) Chef::Log.debug "Overloading #{self.resource_name} load_prior_resource with NOOP" end |