Class: Spatula::Cook
- Inherits:
-
SshCommand
- Object
- SshCommand
- Spatula::Cook
- Defined in:
- lib/spatula/cook.rb
Overview
Where to find upstream cookbooks
Instance Method Summary collapse
-
#initialize(server, node, port = nil, login = nil, identity = nil, log_level = nil) ⇒ Cook
constructor
A new instance of Cook.
- #run ⇒ Object
Methods inherited from SshCommand
run, #ssh, #ssh_command, #ssh_opts
Constructor Details
#initialize(server, node, port = nil, login = nil, identity = nil, log_level = nil) ⇒ Cook
Returns a new instance of Cook.
6 7 8 9 10 |
# File 'lib/spatula/cook.rb', line 6 def initialize(server, node, port=nil, login=nil, identity=nil, log_level=nil) super(server, port, login, identity) @node = node @log_level = log_level end |
Instance Method Details
#run ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/spatula/cook.rb', line 12 def run Dir["**/*.rb"].each do |recipe| ok = sh "ruby -c #{recipe} >/dev/null 2>&1" raise "Syntax error in #{recipe}" if not ok end Dir["**/*.json"].each do |json| begin require 'json' # parse without instantiating Chef classes JSON.parse File.read(json), :create_additions => false rescue => error raise "Syntax error in #{json}: #{error.}" end end if @server =~ /^local$/i sh chef_cmd else sh "rsync -rlP --rsh=\"ssh #{ssh_opts}\" --delete --exclude '.*' ./ #@server:#{REMOTE_CHEF_PATH}" ssh "cd #{REMOTE_CHEF_PATH}; #{chef_cmd}" end end |