Class: Packer::Builder

Inherits:
DataObject show all
Defined in:
lib/packer/builder.rb,
lib/packer/builders/null.rb,
lib/packer/builders/qemu.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, Qemu, VMWareISO, VMWareVMX, VirtualBoxISO

Defined Under Namespace

Classes: Amazon, Docker, Null, Qemu, 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'
QEMU =
'qemu'
NULL =
'null'
VALID_BUILDER_TYPES =
[
  AMAZON_EBS,
  AMAZON_INSTANCE,
  DOCKER,
  VIRTUALBOX_ISO,
  VMWARE_VMX,
  VMWARE_ISO,
  QEMU,
  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.



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

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

Instance Attribute Details

#communicatorsObject

Returns the value of attribute communicators.



46
47
48
# File 'lib/packer/builder.rb', line 46

def communicators
  @communicators
end

Class Method Details

.get_builder(type) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/packer/builder.rb', line 29

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,
    QEMU            => Packer::Builder::Qemu,
    NULL            => Packer::Builder::Null
  }.fetch(type).new
end

.typesObject



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

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



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

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

  self.__add_string('communicator', comm)
end

#name(name) ⇒ Object



58
59
60
# File 'lib/packer/builder.rb', line 58

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

#ssh_bastion_host(hostname) ⇒ Object



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

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

#ssh_bastion_password(password) ⇒ Object



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

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

#ssh_bastion_private_key_file(filename) ⇒ Object



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

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

#ssh_bastion_username(username) ⇒ Object



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

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

#ssh_disable_agent(disable) ⇒ Object



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

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

#ssh_handshake_attempts(attempts) ⇒ Object



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

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



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

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

#ssh_password(password) ⇒ Object



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

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

#ssh_port(port) ⇒ Object



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

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

#ssh_private_key_file(filename) ⇒ Object



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

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

#ssh_pty(pty) ⇒ Object



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

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

#ssh_timeout(timeout) ⇒ Object



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

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

#ssh_username(username) ⇒ Object



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

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

#winrm_host(host) ⇒ Object

Technically these only apply if the communicator is winrm



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

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

#winrm_password(password) ⇒ Object



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

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

#winrm_port(port) ⇒ Object



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

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

#winrm_timeout(timeout) ⇒ Object



141
142
143
# File 'lib/packer/builder.rb', line 141

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

#winrm_username(username) ⇒ Object



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

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