Class: SousChef::Node

Inherits:
Object
  • Object
show all
Defined in:
lib/sous-chef/node.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, settings) ⇒ Node

Returns a new instance of Node.



6
7
8
9
# File 'lib/sous-chef/node.rb', line 6

def initialize(name, settings)
  @settings = settings
  @name = name
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



2
3
4
# File 'lib/sous-chef/node.rb', line 2

def name
  @name
end

Instance Method Details

#configObject



11
12
13
# File 'lib/sous-chef/node.rb', line 11

def config
  @config ||= @settings['node_config'] || {}
end

#hostnameObject



15
16
17
# File 'lib/sous-chef/node.rb', line 15

def hostname
  @hostname ||= ssh_hash['Host'] || @name
end

#ssh_configObject



19
20
21
22
23
24
25
26
27
# File 'lib/sous-chef/node.rb', line 19

def ssh_config
  @ssh_config ||= begin
    config = "Host #{hostname}\n"
     ssh_attrs.each do |key, value|
       config << "  #{key} #{value}\n"
     end
     config
   end
end

#ssh_config_pathObject



29
30
31
32
33
34
35
36
37
38
# File 'lib/sous-chef/node.rb', line 29

def ssh_config_path
  @ssh_config_file ||= begin
    config_file = Tempfile.new('agent_ssh_config')
    config_file.write(ssh_config)
    config_file.close
    at_exit { config_file.delete }
    config_file
  end
  @ssh_config_file.path
end