lib/beaker/dsl/helpers/host_helpers.rb in beaker-2.13.0 vs lib/beaker/dsl/helpers/host_helpers.rb in beaker-2.14.0

- old
+ new

@@ -372,15 +372,11 @@ # @param [String, Command] cmd The curl command to execute on *host*. # @param [Proc] block Additional actions or assertions. # @!macro common_opts # def curl_on(host, cmd, opts = {}, &block) - if options.is_pe? #check global options hash - on host, "curl --tlsv1 %s" % cmd, opts, &block - else - on host, "curl %s" % cmd, opts, &block - end + on host, "curl --tlsv1 %s" % cmd, opts, &block end def curl_with_retries(desc, host, url, desired_exit_codes, max_retries = 60, retry_interval = 1) opts = { @@ -502,9 +498,25 @@ dir = host.tmpdir(path_prefix) on host, "chown #{user}:#{user} #{dir}" dir else raise "Host platform not supported by `create_tmpdir_on`." + end + end + end + + # 'echo' the provided value on the given host(s) + # @param [Host, Array<Host>, String, Symbol] hosts One or more hosts to act upon, + # or a role (String or Symbol) that identifies one or more hosts. + # @param [String] val The string to 'echo' on the host(s) + # @return [String, Array<String> The echo'ed value(s) returned by the host(s) + def echo_on hosts, val + #val = val.gsub(/"/, "\"").gsub(/\(/, "\(") + block_on hosts do |host| + if host.is_powershell? + host.exec(Command.new("echo #{val}")).stdout.chomp + else + host.exec(Command.new("echo \"#{val}\"")).stdout.chomp end end end