Class: SousChef::Node
- Inherits:
-
Object
- Object
- SousChef::Node
- Defined in:
- lib/sous-chef/node.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #config ⇒ Object
- #hostname ⇒ Object
-
#initialize(name, settings) ⇒ Node
constructor
A new instance of Node.
- #ssh_config ⇒ Object
- #ssh_config_path ⇒ Object
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
#name ⇒ Object (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
#config ⇒ Object
11 12 13 |
# File 'lib/sous-chef/node.rb', line 11 def config @config ||= @settings['node_config'] || {} end |
#hostname ⇒ Object
15 16 17 |
# File 'lib/sous-chef/node.rb', line 15 def hostname @hostname ||= ssh_hash['Host'] || @name end |
#ssh_config ⇒ Object
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_path ⇒ Object
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 |