Class: Pec::Handler::Templates
- Defined in:
- lib/pec/handler/templates.rb
Class Method Summary collapse
Class Method Details
.build(host) ⇒ Object
5 6 7 |
# File 'lib/pec/handler/templates.rb', line 5 def build(host) { user_data: load_template(host) } end |
.load_template(host) ⇒ Object
9 10 11 12 13 14 15 16 17 |
# File 'lib/pec/handler/templates.rb', line 9 def load_template(host) host.templates.inject({}) do |merge_template, template| template.to_s.concat('.yaml') unless template.to_s.match(/.*\.yaml/) Pec::Logger.notice "load template #{template}" raise "#{template} not fond!" unless FileTest.exist?("user_data/#{template}") merge_template.deep_merge!(YAML.load_file("user_data/#{template}").to_hash) end if host.templates end |