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.



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

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

Instance Attribute Details

#communicatorsObject

Returns the value of attribute communicators.



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

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
# 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



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

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



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

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

#name(name) ⇒ Object



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

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

#ssh_bastion_host(hostname) ⇒ Object



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

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

#ssh_bastion_password(password) ⇒ Object



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

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

#ssh_bastion_private_key_file(filename) ⇒ Object



118
119
120
# File 'lib/packer/builder.rb', line 118

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

#ssh_bastion_username(username) ⇒ Object



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

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

#ssh_disable_agent(disable) ⇒ Object



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

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

#ssh_handshake_attempts(attempts) ⇒ Object



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

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



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

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

#ssh_password(password) ⇒ Object



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

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

#ssh_port(port) ⇒ Object



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

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

#ssh_private_key_file(filename) ⇒ Object



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

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

#ssh_pty(pty) ⇒ Object



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

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

#ssh_timeout(timeout) ⇒ Object



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

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

#ssh_username(username) ⇒ Object



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

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

#winrm_host(host) ⇒ Object

Technically these only apply if the communicator is winrm



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

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

#winrm_password(password) ⇒ Object



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

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

#winrm_port(port) ⇒ Object



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

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

#winrm_timeout(timeout) ⇒ Object



139
140
141
# File 'lib/packer/builder.rb', line 139

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

#winrm_username(username) ⇒ Object



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

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