0
在我的capistrano任務中,我打電話給superfunction
方法。不幸的是,它拋出了Unexpected Return
錯誤。我需要從superfunction
方法中獲取輸出,以便在我的任務中進一步解析它。從Ruby方法返回變量/數組時出錯
def superfunction(cmd_type, command, client)
run "#{command}" do |channel, stream, data|
hostname = "#{channel[:host]}".tr('"','')
result = "#{data}".to_s.strip
return hostname, result
end
end
task :gather, :roles => :hosts do
...
servername, redhat_version = superfunction("redhat_version", "cat /etc/redhat-release", client)
end