-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathalma8.pkr.hcl
More file actions
204 lines (197 loc) · 6.87 KB
/
alma8.pkr.hcl
File metadata and controls
204 lines (197 loc) · 6.87 KB
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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
packer {
required_plugins {
azure = {
source = "github.com/hashicorp/azure"
version = "~> 1"
}
ansible = {
source = "github.com/hashicorp/ansible"
version = "~> 1"
}
vagrant = {
source = "github.com/hashicorp/vagrant"
version = "~> 1"
}
hyperv = {
source = "github.com/hashicorp/hyperv"
version = "~> 1"
}
vmware = {
version = "~> 1"
source = "github.com/hashicorp/vmware"
}
}
}
source "azure-arm" "alma8" {
azure_tags = {
product = "${var.image}"
}
plan_info {
plan_name = "8-gen2"
plan_product = "almalinux"
plan_publisher = "almalinux"
}
image_offer = "almalinux"
image_publisher = "almalinux"
image_sku = "8-gen2"
location = "${var.location}"
managed_image_name = "${var.image}"
managed_image_resource_group_name = "${var.managed_image_resource_group_name}"
os_disk_size_gb = "30"
os_type = "Linux"
client_id = "${var.client_id}"
client_secret = "${var.client_secret}"
tenant_id = "${var.tenant_id}"
subscription_id = "${var.subscription_id}"
use_azure_cli_auth = false
vm_size = "Standard_DS2_v2"
}
# https://developer.hashicorp.com/packer/plugins/builders/hyperv/iso
source "hyperv-iso" "alma8" {
boot_command = [
"c<wait>",
"linuxefi /images/pxeboot/vmlinuz inst.stage2=hd:LABEL=AlmaLinux-8-8-x86_64-dvd ro ",
"inst.text biosdevname=0 net.ifnames=0 ",
"inst.ks=http://{{ .HTTPIP }}:{{ .HTTPPort }}/ks.cfg<enter>",
"initrdefi /images/pxeboot/initrd.img<enter>",
"boot<enter><wait>"
]
boot_wait = "5s"
communicator = "ssh"
cpus = 2
disk_size = 65536
disk_block_size = 1
enable_secure_boot = true
enable_mac_spoofing = true
secure_boot_template = "MicrosoftUEFICertificateAuthority"
generation = 2
guest_additions_mode = "disable"
headless = true
http_directory = "kickstart"
keep_registered = false
iso_checksum = "${var.iso_checksum}"
iso_urls = ["${var.iso_url1}", "${var.iso_url2}"]
mac_address = "00c0dedec0de"
memory = 2048
shutdown_command = "sudo -S shutdown -P now"
shutdown_timeout = "30m"
ssh_password = "vagrant"
ssh_username = "root"
ssh_wait_timeout = "10000s"
switch_name = "Wi-Fi"
vm_name = "alma8-vm"
vlan_id = ""
}
source "virtualbox-iso" "alma8" {
boot_command = [
"c<wait>",
"linuxefi /images/pxeboot/vmlinuz inst.stage2=hd:LABEL=AlmaLinux-8-8-x86_64-dvd ro ",
"inst.text biosdevname=0 net.ifnames=0 ",
"inst.ks=http://{{ .HTTPIP }}:{{ .HTTPPort }}/ks.cfg<enter>",
"initrdefi /images/pxeboot/initrd.img<enter>",
"boot<enter><wait>"
]
boot_wait = "5s"
cpus = 2
disk_size = 65536
firmware = "efi"
gfx_controller = "vmsvga"
gfx_efi_resolution = "1920x1080"
gfx_vram_size = "128"
guest_os_type = "RedHat_64"
guest_additions_mode = "disable"
hard_drive_interface = "sata"
hard_drive_nonrotational = true
headless = true
http_directory = "kickstart"
iso_checksum = "${var.iso_checksum}"
iso_interface = "ide"
iso_urls = ["${var.iso_url1}", "${var.iso_url2}"]
keep_registered = false
memory = 4096
nested_virt = true
rtc_time_base = "UTC"
shutdown_command = "echo 'vagrant' | sudo -S /sbin/halt -h -p"
ssh_password = "vagrant"
ssh_username = "root"
ssh_wait_timeout = "10000s"
usb = true
vboxmanage = [
["modifyvm", "{{.Name}}", "--firmware", "EFI"],
["modifyvm", "{{.Name}}", "--macaddress1", "auto"],
["modifyvm", "{{.Name}}", "--macaddress2", "00c0dedec0de"],
["modifyvm", "{{.Name}}", "--usbehci", "on"],
]
virtualbox_version_file = ".vbox_version"
vrdp_bind_address = "0.0.0.0"
vrdp_port_min = "5900"
vrdp_port_max = "5900"
vm_name = "alma8-vm"
}
source "vmware-iso" "alma8" {
boot_command = [
"<tab>",
"inst.text net.ifnames=0 inst.ks=http://{{ .HTTPIP }}:{{ .HTTPPort }}/ks.cfg",
"<enter><wait>"
]
boot_wait = "5s"
cpus = 2
disk_size = 65536
guest_os_type = "Linux"
headless = false
http_directory = "kickstart"
iso_checksum = "${var.iso_checksum}"
iso_urls = ["${var.iso_url1}", "${var.iso_url2}"]
memory = 4096
ssh_username = "root"
ssh_password = "vagrant"
ssh_wait_timeout = "10000s"
shutdown_command = "shutdown -P now"
}
build {
sources = ["source.virtualbox-iso.alma8", "source.hyperv-iso.alma8", "source.vmware-iso.alma8", "source.azure-arm.alma8"]
provisioner "shell" {
only = ["hyperv-iso.alma8", "virtualbox-iso.alma8","vmware-iso.alma8"]
execute_command = "bash '{{ .Path }}'"
script = "scripts/vagrant.sh"
}
provisioner "shell" {
only = ["hyperv-iso.alma8", "virtualbox-iso.alma8","vmware-iso.alma8"]
environment_vars = [
"PROXY=${var.proxy_proto}://${var.proxy_user}:${var.proxy_password}@${var.proxy_host}:${var.proxy_port}"
]
execute_command = "{{ .Vars }} bash '{{ .Path }}'"
script = "scripts/ansible.sh"
}
provisioner "ansible-local" {
extra_arguments = [ "-vv",
"-e", "ansible_python_interpreter=/usr/libexec/platform-python",
"-e", "proxy_proto=${var.proxy_proto}",
"-e", "proxy_host=${var.proxy_host}",
"-e", "proxy_port=${var.proxy_port}",
"-e", "proxy_user=${var.proxy_user}",
"-e", "proxy_password=${var.proxy_password}", ]
galaxy_file = "./ansible/roles/requirements.yml"
galaxy_command = "${var.https_proxy} ansible-galaxy"
playbook_dir = "./ansible"
playbook_file = "./ansible/packer-playbook.yml"
}
provisioner "shell" {
only = ["azure-arm.alma8"]
execute_command = "chmod +x {{ .Path }}; {{ .Vars }} sudo -E sh '{{ .Path }}'"
inline = [
"/usr/sbin/waagent -force -deprovision+user",
"sync"
]
inline_shebang = "/bin/sh -x"
}
post-processors {
post-processor "vagrant" {
except = ["azure-arm.alma8"]
keep_input_artifact = true
compression_level = 9
output = "output-alma8/alma8.x86_64.{{.Provider}}.box"
vagrantfile_template = "Vagrantfile.template"
}
}
}