Method: Beaker::HostPrebuiltSteps#set_env

Defined in:
lib/beaker/host_prebuilt_steps.rb

#set_env(host, opts) ⇒ Object

Add a host specific set of env vars to each provided host’s ~/.ssh/environment

Parameters:

  • host (Host, Array<Host>)

    One or more hosts to act upon

  • opts (Hash{Symbol=>String})

    Options to alter execution.



534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
# File 'lib/beaker/host_prebuilt_steps.rb', line 534

def set_env host, opts
  logger = opts[:logger]

  block_on host do |host|
    skip_msg = host.skip_set_env?
    unless skip_msg.nil?
      logger.debug( skip_msg )
      next
    end

    env = construct_env(host, opts)
    logger.debug("setting local environment on #{host.name}")
    if host['platform'] =~ /windows/ and host.is_cygwin?
      env['CYGWIN'] = 'nodosfilewarning'
    end
    host.ssh_permit_user_environment()

    host.ssh_set_user_environment(env)

    # REMOVE POST BEAKER 3: backwards compatability, do some setup based upon the global type
    # this is the worst and i hate it
    Class.new.extend(Beaker::DSL).configure_type_defaults_on(host)

    #close the host to re-establish the connection with the new sshd settings
    host.close

    # print out the working env
    if host.is_powershell?
      host.exec(Command.new("SET"))
    else
      host.exec(Command.new("cat #{host[:ssh_env_file]}"))
    end

  end
end