Class: Foreman::Provision::SSH

Inherits:
Object
  • Object
show all
Defined in:
lib/foreman/provision/ssh.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(address, username = "root", options = { }) ⇒ SSH


7
8
9
10
11
12
13
14
15
# File 'lib/foreman/provision/ssh.rb', line 7

def initialize address, username = "root", options = { }
  @username = username
  @address  = address
  @template = options.delete(:template) || raise("must provide a template")
  @uuid     = options.delete(:uuid)     || "#{address}-#{username}"
  @options  = defaults.merge(options)

  initiate_connection!
end

Instance Attribute Details

#addressObject (readonly)

Returns the value of attribute address


5
6
7
# File 'lib/foreman/provision/ssh.rb', line 5

def address
  @address
end

#optionsObject (readonly)

Returns the value of attribute options


5
6
7
# File 'lib/foreman/provision/ssh.rb', line 5

def options
  @options
end

#resultsObject (readonly)

Returns the value of attribute results


5
6
7
# File 'lib/foreman/provision/ssh.rb', line 5

def results
  @results
end

#templateObject (readonly)

Returns the value of attribute template


5
6
7
# File 'lib/foreman/provision/ssh.rb', line 5

def template
  @template
end

#usernameObject (readonly)

Returns the value of attribute username


5
6
7
# File 'lib/foreman/provision/ssh.rb', line 5

def username
  @username
end

#uuidObject (readonly)

Returns the value of attribute uuid


5
6
7
# File 'lib/foreman/provision/ssh.rb', line 5

def uuid
  @uuid
end

Instance Method Details

#deploy!Object


17
18
19
20
21
22
23
24
25
# File 'lib/foreman/provision/ssh.rb', line 17

def deploy!
  logger.debug "about to upload #{template} to remote system at #{remote_script}"
  scp.upload(template, remote_script)
  logger.debug "about to execute #{command}"
  @results = ssh.run(command)
  log_stdout
  log_stderr
  success?
end