Class: Skewer::PuppetNode

Inherits:
Object
  • Object
show all
Defined in:
lib/puppet_node.rb

Overview

responsible for creating a node definition

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(nodes = { :default =>:noop}) ⇒ PuppetNode

Returns a new instance of PuppetNode.



6
7
8
9
10
# File 'lib/puppet_node.rb', line 6

def initialize(nodes = { :default =>:noop})
  @nodes = nodes
  config = SkewerConfig.instance
  @puppet_repo = config.get(:puppet_repo)
end

Instance Attribute Details

#nodesObject

Returns the value of attribute nodes.



4
5
6
# File 'lib/puppet_node.rb', line 4

def nodes
  @nodes
end

#puppet_repoObject

Returns the value of attribute puppet_repo.



4
5
6
# File 'lib/puppet_node.rb', line 4

def puppet_repo
  @puppet_repo
end

Instance Method Details

#renderObject



19
20
21
22
23
24
# File 'lib/puppet_node.rb', line 19

def render
  node_file_path = File.join(@puppet_repo, 'manifests','nodes.pp')
  file = File.new(node_file_path, 'w+')
  file << self.to_s
  file.close
end

#to_sObject



12
13
14
15
16
17
# File 'lib/puppet_node.rb', line 12

def to_s
  require 'erb'
  lib_dir = File.dirname(__FILE__)
  template = ERB.new(File.read(File.join(lib_dir, 'node.erb')))
  template.result(binding)
end