Method: Beaker::HostPrebuiltSteps#sync_root_keys

Defined in:
lib/beaker/host_prebuilt_steps.rb

#sync_root_keys(host, opts) ⇒ Object

Install a set of authorized keys using ROOT_KEYS_SCRIPT. This is a convenience method to allow for easy login to hosts after they have been provisioned with Beaker.

Parameters:

  • host (Host, Array<Host>)

    One or more hosts to act upon

  • opts (Hash{Symbol=>String})

    Options to alter execution.

Options Hash (opts):



139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
# File 'lib/beaker/host_prebuilt_steps.rb', line 139

def sync_root_keys host, opts
  # JJM This step runs on every system under test right now.  We're anticipating
  # issues on Windows and maybe Solaris.  We will likely need to filter this step
  # but we're deliberately taking the approach of "assume it will work, fix it
  # when reality dictates otherwise"
  logger = opts[:logger]
  block_on host do |host|
  logger.notify "Sync root authorized_keys from github on #{host.name}"
    # Allow all exit code, as this operation is unlikely to cause problems if it fails.
    if host['platform'] =~ /solaris|eos/
      host.exec(Command.new(ROOT_KEYS_SYNC_CMD % "bash"), :accept_all_exit_codes => true)
    elsif host['platform'] =~ /aix/
      host.exec(Command.new(ROOT_KEYS_SYNC_CMD_AIX % "env PATH=/usr/gnu/bin:$PATH bash"), :accept_all_exit_codes => true)
    else
      host.exec(Command.new(ROOT_KEYS_SYNC_CMD % "env PATH=/usr/gnu/bin:$PATH bash"), :accept_all_exit_codes => true)
    end
  end
rescue => e
  report_and_raise(logger, e, "sync_root_keys")
end