Class: Wombat::BuildRunner

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Crypto

#gen_ssh_key, #gen_x509_cert

Methods included from Common

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

Constructor Details

#initialize(opts) ⇒ BuildRunner

Returns a new instance of BuildRunner.



17
18
19
20
21
22
23
24
# File 'lib/wombat/build.rb', line 17

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

Instance Attribute Details

#builderObject (readonly)

Returns the value of attribute builder.



15
16
17
# File 'lib/wombat/build.rb', line 15

def builder
  @builder
end

#parallelObject (readonly)

Returns the value of attribute parallel.



15
16
17
# File 'lib/wombat/build.rb', line 15

def parallel
  @parallel
end

#templatesObject (readonly)

Returns the value of attribute templates.



15
16
17
# File 'lib/wombat/build.rb', line 15

def templates
  @templates
end

Instance Method Details

#startObject



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/wombat/build.rb', line 26

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

  # If running on azure ensure that the resource group and storage account exist
  prepare_azure if builder == "azure-arm"

  time = Benchmark.measure do
    banner("Starting build for templates: #{templates}")
    aws_region_check if builder == 'amazon-ebs'
    templates.each do |t|
      vendor_cookbooks(t) unless @no_vendor
    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}\" for you") if audio?
  banner("Build finished in #{duration(time.real)}.")
end