Class: Kontena::Machine::CloudConfig::NodeGenerator

Inherits:
Object
  • Object
show all
Defined in:
lib/kontena/machine/cloud_config/node_generator.rb

Instance Method Summary collapse

Instance Method Details

#erb(template, vars) ⇒ Object

Parameters:

  • template (String)
  • vars (Hash)


22
23
24
# File 'lib/kontena/machine/cloud_config/node_generator.rb', line 22

def erb(template, vars)
  ERB.new(template).result(OpenStruct.new(vars).instance_eval { binding })
end

#generate(opts) ⇒ Object

Parameters:

  • opts (Hash)


10
11
12
# File 'lib/kontena/machine/cloud_config/node_generator.rb', line 10

def generate(opts)
  user_data(opts)
end

#user_data(vars) ⇒ Object

Parameters:

  • vars (Hash)


15
16
17
18
# File 'lib/kontena/machine/cloud_config/node_generator.rb', line 15

def user_data(vars)
  cloudinit_template = File.join(__dir__ , '/cloudinit.yml')
  erb(File.read(cloudinit_template), vars)
end