在我的 capistrano 任务中,我正在调用该superfunction
方法。不幸的是,它抛出了一个Unexpected Return
错误。我需要从superfunction
方法中获取输出,以便在我的任务中进一步解析它。
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