Class: Foreman::Provision::SSH

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of SSH.


6
7
8
9
10
11
12
13
14
# File 'app/services/foreman/provision/ssh.rb', line 6

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


4
5
6
# File 'app/services/foreman/provision/ssh.rb', line 4

def address
  @address
end

#optionsObject (readonly)

Returns the value of attribute options


4
5
6
# File 'app/services/foreman/provision/ssh.rb', line 4

def options
  @options
end

#resultsObject (readonly)

Returns the value of attribute results


4
5
6
# File 'app/services/foreman/provision/ssh.rb', line 4

def results
  @results
end

#templateObject (readonly)

Returns the value of attribute template


4
5
6
# File 'app/services/foreman/provision/ssh.rb', line 4

def template
  @template
end

#usernameObject (readonly)

Returns the value of attribute username


4
5
6
# File 'app/services/foreman/provision/ssh.rb', line 4

def username
  @username
end

#uuidObject (readonly)

Returns the value of attribute uuid


4
5
6
# File 'app/services/foreman/provision/ssh.rb', line 4

def uuid
  @uuid
end

Instance Method Details

#deploy!Object


16
17
18
19
20
21
22
23
24
# File 'app/services/foreman/provision/ssh.rb', line 16

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