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?, #azure_provider_tag, #banner, #bootstrap_aws, #build_nodes, #calculate_templates, #conf, #connect_azure, #create_infranodes_json, #create_resource_group, #deployment_state, #duration, #follow_azure_deployment, #info, #infranodes, #is_mac?, #is_valid_json?, #linux, #list_outstanding_deployment_operations, #lock, #logs, #parse_log, #update_lock, #update_template, #warn, #wombat, #workstations

Constructor Details

#initialize(opts) ⇒ BuildRunner

Returns a new instance of BuildRunner.



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

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.



17
18
19
# File 'lib/wombat/build.rb', line 17

def builder
  @builder
end

#parallelObject (readonly)

Returns the value of attribute parallel.



17
18
19
# File 'lib/wombat/build.rb', line 17

def parallel
  @parallel
end

#storage_access_keyObject (readonly)

Returns the value of attribute storage_access_key.



17
18
19
# File 'lib/wombat/build.rb', line 17

def storage_access_key
  @storage_access_key
end

#templatesObject (readonly)

Returns the value of attribute templates.



17
18
19
# File 'lib/wombat/build.rb', line 17

def templates
  @templates
end

Instance Method Details

#startObject



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
58
59
60
61
62
63
# File 'lib/wombat/build.rb', line 28

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

  # Copy the images to the correct location if running Azure builder
  azure_copy_images if builder == "azure-arm"

  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