-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathopensuse.pkr.hcl
171 lines (141 loc) · 3.26 KB
/
opensuse.pkr.hcl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
packer {
required_plugins {
vsphere = {
version = ">= 0.0.1"
source = "github.com/hashicorp/vsphere"
}
}
}
variable "cpu_num" {
type = number
default = 2
}
variable "disk_size" {
type = number
default = 51200
}
variable "mem_size" {
type = number
default = 2048
}
variable "os_iso_checksum" {
type = string
default = ""
}
variable "os_iso_url" {
type = string
default = ""
}
variable "vsphere_datastore" {
type = string
default = ""
}
variable "vsphere_datacenter" {
type = string
default = ""
}
variable "vsphere_guest_os_type" {
type = string
default = ""
}
variable "vsphere_host" {
type = string
default = ""
}
variable "vsphere_password" {
type = string
default = ""
sensitive = true
}
variable "vsphere_network" {
type = string
default = ""
}
variable "vsphere_server" {
type = string
default = ""
}
variable "vsphere_vm_name" {
type = string
default = ""
}
variable "vsphere_username" {
type = string
default = ""
}
variable "ssh_password" {
type = string
default = ""
sensitive = true
}
variable "ssh_username" {
type = string
default = ""
}
variable "cloudinit_files" {
type = list(string)
description = "user-data and meta-data."
default = []
}
variable "shell_scripts" {
type = list(string)
description = "A list of scripts."
default = []
}
variable "boot_command" {
type = list(string)
description = "boot command"
default = []
}
source "vsphere-iso" "opensuse" {
vcenter_server = var.vsphere_server
host = var.vsphere_host
username = var.vsphere_username
password = var.vsphere_password
insecure_connection = "true"
datacenter = var.vsphere_datacenter
datastore = var.vsphere_datastore
CPUs = var.cpu_num
RAM = var.mem_size
RAM_reserve_all = true
disk_controller_type = ["pvscsi"]
guest_os_type = var.vsphere_guest_os_type
iso_checksum = var.os_iso_checksum
iso_url = var.os_iso_url
floppy_files = var.cloudinit_files
# floppy_label = "cidata"
network_adapters {
network = var.vsphere_network
network_card = "vmxnet3"
}
storage {
disk_size = var.disk_size
disk_thin_provisioned = true
}
vm_name = var.vsphere_vm_name
convert_to_template = "true"
communicator = "ssh"
ssh_username = var.ssh_username
ssh_password = var.ssh_password
ssh_timeout = "30m"
ssh_handshake_attempts = "100000"
# boot_order = "disk,cdrom,floppy"
boot_wait = "5s"
boot_command = var.boot_command
# shutdown_command = "echo '${var.ssh_password}' | sudo -S -E shutdown -P now"
# shutdown_timeout = "15m"
configuration_parameters = {
"disk.EnableUUID" = "true"
}
}
build {
sources = ["source.vsphere-iso.opensuse"]
provisioner "shell" {
execute_command = "echo '${var.ssh_password}' | {{.Vars}} sudo -S -E bash '{{.Path}}'"
environment_vars = [
"BUILD_USERNAME=${var.ssh_username}",
]
scripts = var.shell_scripts
expect_disconnect = true
}
}