Class: Foreman::Export::Bluepill

Inherits:
Base
  • Object
show all
Defined in:
lib/foreman/export/bluepill.rb

Instance Attribute Summary

Attributes inherited from Base

#engine

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Foreman::Export::Base

Instance Method Details

#export(location, options = {}) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/foreman/export/bluepill.rb', line 6

def export(location, options={})
  error("Must specify a location") unless location

  FileUtils.mkdir_p location

  app = options[:app] || File.basename(engine.directory)
  user = options[:user] || app
  log_root = options[:log] || "/var/log/#{app}"
  template_root = options[:template]

  Dir["#{location}/#{app}.pill"].each do |file|
    say "cleaning up: #{file}"
    FileUtils.rm(file)
  end

  concurrency = Foreman::Utils.parse_concurrency(options[:concurrency])

  master_template = export_template("bluepill", "master.pill.erb", template_root)
  master_config   = ERB.new(master_template).result(binding)
  write_file "#{location}/#{app}.pill", master_config

end