Method: Beaker::HostPrebuiltSteps#package_proxy

Defined in:
lib/beaker/host_prebuilt_steps.rb

#package_proxy(host, opts) ⇒ Object

Setup files for enabling requests to pass to a proxy server This works for the APT package manager on debian and ubuntu and YUM package manager on el, centos, fedora and redhat.

Parameters:

  • host (Host, Array<Host>, String, Symbol)

    One or more hosts to act upon

  • opts (Hash{Symbol=>String})

    Options to alter execution.

Options Hash (opts):



367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
# File 'lib/beaker/host_prebuilt_steps.rb', line 367

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

  block_on host do |host|
    logger.debug("enabling proxy support on #{host.name}")
    case host['platform']
    when /ubuntu/, /debian/
      host.exec(Command.new("echo 'Acquire::http::Proxy \"#{opts[:package_proxy]}/\";' >> /etc/apt/apt.conf.d/10proxy"))
    when /amazon/, /^el-/, /centos/, /fedora/, /redhat/
      host.exec(Command.new("echo 'proxy=#{opts[:package_proxy]}/' >> /etc/yum.conf"))
    when /solaris-11/
      host.exec(Command.new("/usr/bin/pkg unset-publisher solaris || :"))
      host.exec(Command.new("/usr/bin/pkg set-publisher -g %s solaris" % opts[:package_proxy]))
    else
      logger.debug("Attempting to enable package manager proxy support on non-supported platform: #{host.name}: #{host['platform']}")
    end
  end
end