Class: BuildRunner

Inherits:
Object
  • Object
show all
Includes:
Common
Defined in:
lib/wombat/build.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Common

#audio?, #banner, #bootstrap_aws, #build_nodes, #calculate_templates, #conf, #create_infranodes_json, #duration, #gen_ssh_key, #gen_x509_cert, #info, #infranodes, #is_mac?, #linux, #lock, #logs, #parse_log, #update_lock, #update_template, #warn, #wombat, #workstations

Constructor Details

#initialize(opts) ⇒ BuildRunner

Returns a new instance of BuildRunner.



12
13
14
15
16
# File 'lib/wombat/build.rb', line 12

def initialize(opts)
  @templates = opts.templates.nil? ? calculate_templates : opts.templates
  @builder = opts.builder.nil? ? "amazon-ebs" : opts.builder
  @parallel = opts.parallel
end

Instance Attribute Details

#builderObject (readonly)

Returns the value of attribute builder.



10
11
12
# File 'lib/wombat/build.rb', line 10

def builder
  @builder
end

#parallelObject (readonly)

Returns the value of attribute parallel.



10
11
12
# File 'lib/wombat/build.rb', line 10

def parallel
  @parallel
end

#templatesObject (readonly)

Returns the value of attribute templates.



10
11
12
# File 'lib/wombat/build.rb', line 10

def templates
  @templates
end

Instance Method Details

#startObject



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/wombat/build.rb', line 18

def start
  if which('packer').nil?
    raise "packer binary not found in path, exiting..."
  end
  banner("Generating certs (if necessary)")
  wombat['certs'].each do |hostname|
    gen_x509_cert(hostname)
  end
  banner("Generating SSH keypair (if necessary)")
  gen_ssh_key

  time = Benchmark.measure do
    banner("Starting build for templates: #{templates}")
    aws_region_check if builder == 'amazon-ebs'
    templates.each do |t|
      vendor_cookbooks(t)
    end

    if parallel.nil?
      build_hash.each do |k, v|
        build(v['template'], v['options'])
      end
    else
      build_parallel(templates)
    end
  end
  shell_out_command("say -v fred \"Wombat has made an #{build_hash.keys.to_s}\" for you") if audio?
  banner("Build finished in #{duration(time.real)}.")
end