Class: Packer::Builder

Inherits:
DataObject show all
Defined in:
lib/packer/builder.rb,
lib/packer/builders/null.rb,
lib/packer/builders/amazon.rb,
lib/packer/builders/docker.rb,
lib/packer/builders/virtualbox.rb,
lib/packer/builders/vmware_iso.rb,
lib/packer/builders/vmware_vmx.rb

Direct Known Subclasses

Amazon, Docker, Null, VMWareISO, VMWareVMX, VirtualBoxISO

Defined Under Namespace

Classes: Amazon, Docker, Null, UnrecognizedBuilderTypeError, VMWareISO, VMWareVMX, VirtualBoxISO

Constant Summary collapse

AMAZON_EBS =
'amazon-ebs'
AMAZON_INSTANCE =
'amazon-instance'
DOCKER =
'docker'
VIRTUALBOX_ISO =
'virtualbox-iso'
VMWARE_VMX =
'vmware-vmx'
VMWARE_ISO =
'vmware-iso'
NULL =
'null'
VALID_BUILDER_TYPES =
[
  AMAZON_EBS,
  AMAZON_INSTANCE,
  DOCKER,
  VIRTUALBOX_ISO,
  VMWARE_VMX,
  VMWARE_ISO,
  NULL
]

Instance Attribute Summary collapse

Attributes inherited from DataObject

#data, #key_dependencies, #required

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from DataObject

#__add_array_of_array_of_strings, #__add_array_of_hashes, #__add_array_of_ints, #__add_array_of_strings, #__add_boolean, #__add_hash, #__add_integer, #__add_json, #__add_string, #__exclusive_key_error, #add_key_dependencies, #add_required, #deep_copy, #validate, #validate_key_dependencies, #validate_required

Constructor Details

#initializeBuilder

Returns a new instance of Builder.



48
49
50
51
52
# File 'lib/packer/builder.rb', line 48

def initialize
  super
  self.add_required('type')
  self.communicators = []
end

Instance Attribute Details

#communicatorsObject

Returns the value of attribute communicators.



42
43
44
# File 'lib/packer/builder.rb', line 42

def communicators
  @communicators
end

Class Method Details

.get_builder(type) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/packer/builder.rb', line 27

def self.get_builder(type)
  unless validate_type(type)
    raise UnrecognizedBuilderTypeError.new("Unrecognized builder type #{type}")
  end
  {
    AMAZON_EBS      => Packer::Builder::Amazon::EBS,
    AMAZON_INSTANCE => Packer::Builder::Amazon::Instance,
    DOCKER          => Packer::Builder::Docker,
    VIRTUALBOX_ISO  => Packer::Builder::VirtualBoxISO,
    VMWARE_VMX      => Packer::Builder::VMWareVMX,
    VMWARE_ISO      => Packer::Builder::VMWareISO,
    NULL            => Packer::Builder::Null
  }.fetch(type).new
end

.typesObject



44
45
46
# File 'lib/packer/builder.rb', line 44

def self.types
  VALID_BUILDER_TYPES
end

Instance Method Details

#communicator(comm) ⇒ Object

@ianchesal: Communicators are technically Templates in Packer land but they modify Builders. Weird. So we’ll treat them as Builder attributes. See: packer.io/docs/templates/communicator.html



61
62
63
64
# File 'lib/packer/builder.rb', line 61

def communicator(comm)
  raise(DataValidationError, "unknown communicator protocol #{comm}") unless communicators.include? comm
  self.__add_string('communicator', comm)
end

#name(name) ⇒ Object



54
55
56
# File 'lib/packer/builder.rb', line 54

def name(name)
  self.__add_string('name', name)
end

#ssh_bastion_host(hostname) ⇒ Object



103
104
105
# File 'lib/packer/builder.rb', line 103

def ssh_bastion_host(hostname)
  self.__add_string('ssh_bastion_host', hostname)
end

#ssh_bastion_password(password) ⇒ Object



111
112
113
# File 'lib/packer/builder.rb', line 111

def ssh_bastion_password(password)
  self.__add_string('ssh_bastion_password', password)
end

#ssh_bastion_private_key_file(filename) ⇒ Object



115
116
117
# File 'lib/packer/builder.rb', line 115

def ssh_bastion_private_key_file(filename)
  self.__add_string('ssh_bastion_private_key_file', filename)
end

#ssh_bastion_username(username) ⇒ Object



107
108
109
# File 'lib/packer/builder.rb', line 107

def ssh_bastion_username(username)
  self.__add_string('ssh_bastion_username', username)
end

#ssh_disable_agent(disable) ⇒ Object



99
100
101
# File 'lib/packer/builder.rb', line 99

def ssh_disable_agent(disable)
  self.__add_boolean('ssh_disable_agent', disable)
end

#ssh_handshake_attempts(attempts) ⇒ Object



95
96
97
# File 'lib/packer/builder.rb', line 95

def ssh_handshake_attempts(attempts)
  self.__add_integer('ssh_handshake_attempts', attempts)
end

#ssh_host(host) ⇒ Object

Technically these only apply if the communicator is ssh



67
68
69
# File 'lib/packer/builder.rb', line 67

def ssh_host(host)
  self.__add_string('ssh_host', host)
end

#ssh_password(password) ⇒ Object



79
80
81
# File 'lib/packer/builder.rb', line 79

def ssh_password(password)
  self.__add_string('ssh_password', password)
end

#ssh_port(port) ⇒ Object



71
72
73
# File 'lib/packer/builder.rb', line 71

def ssh_port(port)
  self.__add_integer('ssh_port', port)
end

#ssh_private_key_file(filename) ⇒ Object



83
84
85
# File 'lib/packer/builder.rb', line 83

def ssh_private_key_file(filename)
  self.__add_string('ssh_private_key_file', filename)
end

#ssh_pty(pty) ⇒ Object



87
88
89
# File 'lib/packer/builder.rb', line 87

def ssh_pty(pty)
  self.__add_boolean('ssh_pty', pty)
end

#ssh_timeout(timeout) ⇒ Object



91
92
93
# File 'lib/packer/builder.rb', line 91

def ssh_timeout(timeout)
  self.__add_string('ssh_timeout', timeout)
end

#ssh_username(username) ⇒ Object



75
76
77
# File 'lib/packer/builder.rb', line 75

def ssh_username(username)
  self.__add_string('ssh_username', username)
end

#winrm_host(host) ⇒ Object

Technically these only apply if the communicator is winrm



120
121
122
# File 'lib/packer/builder.rb', line 120

def winrm_host(host)
  self.__add_string('winrm_host', host)
end

#winrm_password(password) ⇒ Object



132
133
134
# File 'lib/packer/builder.rb', line 132

def winrm_password(password)
  self.__add_string('winrm_password', password)
end

#winrm_port(port) ⇒ Object



124
125
126
# File 'lib/packer/builder.rb', line 124

def winrm_port(port)
  self.__add_string('winrm_port', port)
end

#winrm_timeout(timeout) ⇒ Object



136
137
138
# File 'lib/packer/builder.rb', line 136

def winrm_timeout(timeout)
  self.__add_string('winrm_timeout', timeout)
end

#winrm_username(username) ⇒ Object



128
129
130
# File 'lib/packer/builder.rb', line 128

def winrm_username(username)
  self.__add_string('winrm_username', username)
end