Method: Beaker::HostPrebuiltSteps#construct_env

Defined in:
lib/beaker/host_prebuilt_steps.rb

#construct_env(host, opts) ⇒ Hash

Create the hash of default environment from host (:host_env), global options hash (:host_env) and default PE/Foss puppet variables

Parameters:

  • host (Host)

    The host to construct the environment hash for, host specific environment should be in :host_env in a hash

  • opts (Hash)

    Hash of options, including optional global host_env to be applied to each provided host

Returns:

  • (Hash)

    A hash of environment variables for provided host



453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
# File 'lib/beaker/host_prebuilt_steps.rb', line 453

def construct_env host, opts
  env = additive_hash_merge(host[:host_env], opts[:host_env])

  #Add PATH

  #prepend any PATH already set for this host

  env['PATH'] = (%w(puppetbindir facterbindir hierabindir) << env['PATH']).compact.reject(&:empty?)
  #get the PATH defaults
  env['PATH'].map! { |val| host[val] }
  env['PATH'] = env['PATH'].compact.reject(&:empty?)
  #run the paths through echo to see if they have any subcommands that need processing
  env['PATH'].map! { |val| echo_on_host(host, val) }

  env.each_key do |key|
    separator = host['pathseparator']
    if key == 'PATH' && host.is_cygwin?
      separator = ':'
    end
    env[key] = env[key].join(separator)
  end
  env
end