Method: Beaker::HostPrebuiltSteps#copy_file_to_remote

Defined in:
lib/beaker/host_prebuilt_steps.rb

#copy_file_to_remote(host, file_path, file_content) ⇒ Object

Create a file on host or hosts at the provided file path with the provided file contents.

Parameters:

  • host (Host, Array<Host>)

    One or more hosts to act upon

  • file_path (String)

    The path at which the new file will be created on the host or hosts.

  • file_content (String)

    The contents of the file to be created on the host or hosts.



166
167
168
169
170
171
172
173
174
# File 'lib/beaker/host_prebuilt_steps.rb', line 166

def copy_file_to_remote(host, file_path, file_content)
  block_on host do |host|
    Tempfile.open 'beaker' do |tempfile|
      File.open(tempfile.path, 'w') { |file| file.puts file_content }

      host.do_scp_to(tempfile.path, file_path, @options)
    end
  end
end