-
Notifications
You must be signed in to change notification settings - Fork 48
/
almalinux-8-vagrant.pkr.hcl
221 lines (208 loc) · 7.56 KB
/
almalinux-8-vagrant.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
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
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
# AlmaLinux OS 8 Packer template for Vagrant boxes
source "qemu" "almalinux-8" {
iso_url = local.iso_url_8_x86_64
iso_checksum = local.iso_checksum_8_x86_64
http_directory = var.http_directory
shutdown_command = var.vagrant_shutdown_command
ssh_username = var.vagrant_ssh_username
ssh_password = var.vagrant_ssh_password
ssh_timeout = var.ssh_timeout
boot_command = local.vagrant_boot_command_8_x86_64
boot_wait = var.boot_wait
accelerator = "kvm"
disk_interface = "virtio-scsi"
disk_size = var.vagrant_disk_size
disk_cache = "unsafe"
disk_discard = "unmap"
disk_detect_zeroes = "unmap"
disk_compression = true
format = "qcow2"
headless = var.headless
machine_type = "q35"
memory = var.memory
net_device = "virtio-net"
qemu_binary = var.qemu_binary
vm_name = "AlmaLinux-8-Vagrant-Libvirt-${var.os_ver_8}-${formatdate("YYYYMMDD", timestamp())}.x86_64.qcow2"
cpu_model = "host"
cpus = var.cpus
efi_boot = true
efi_firmware_code = var.ovmf_code
efi_firmware_vars = var.ovmf_vars
efi_drop_efivars = true
}
source "virtualbox-iso" "almalinux-8" {
iso_url = local.iso_url_8_x86_64
iso_checksum = local.iso_checksum_8_x86_64
http_directory = var.http_directory
shutdown_command = var.vagrant_shutdown_command
ssh_username = var.vagrant_ssh_username
ssh_password = var.vagrant_ssh_password
ssh_timeout = var.ssh_timeout
boot_command = local.vagrant_boot_command_8_x86_64
boot_wait = var.boot_wait
firmware = "efi"
disk_size = var.vagrant_disk_size
guest_os_type = "RedHat_64"
cpus = var.cpus
memory = var.memory
headless = var.headless
hard_drive_interface = "sata"
iso_interface = "sata"
vboxmanage = [["modifyvm", "{{.Name}}", "--nat-localhostreachable1", "on"]]
vboxmanage_post = [
["modifyvm", "{{.Name}}", "--memory", var.post_memory],
["modifyvm", "{{.Name}}", "--cpus", var.post_cpus],
]
}
source "hyperv-iso" "almalinux-8" {
iso_url = local.iso_url_8_x86_64
iso_checksum = local.iso_checksum_8_x86_64
http_directory = var.http_directory
shutdown_command = var.vagrant_shutdown_command
communicator = "ssh"
ssh_username = var.vagrant_ssh_username
ssh_password = var.vagrant_ssh_password
ssh_timeout = var.ssh_timeout
boot_command = local.vagrant_boot_command_8_x86_64
boot_wait = var.boot_wait
disk_size = var.vagrant_disk_size
disk_block_size = 1
memory = var.memory
switch_name = var.hyperv_switch_name
cpus = var.cpus
generation = 2
enable_dynamic_memory = true
headless = var.headless
}
source "vmware-iso" "almalinux-8" {
iso_url = local.iso_url_8_x86_64
iso_checksum = local.iso_checksum_8_x86_64
http_directory = var.http_directory
shutdown_command = var.vagrant_shutdown_command
ssh_username = var.vagrant_ssh_username
ssh_password = var.vagrant_ssh_password
ssh_timeout = var.ssh_timeout
boot_command = var.vagrant_boot_command_8_x86_64_bios
boot_wait = var.boot_wait
disk_size = var.vagrant_disk_size
guest_os_type = "centos-64"
cpus = var.cpus
memory = var.memory
headless = var.headless
vmx_remove_ethernet_interfaces = true
vmx_data = {
"cpuid.coresPerSocket" = "1"
}
vmx_data_post = {
"memsize" = var.post_memory
"numvcpus" = var.post_cpus
}
}
source "parallels-iso" "almalinux-8" {
iso_url = local.iso_url_8_x86_64
iso_checksum = local.iso_checksum_8_x86_64
http_directory = var.http_directory
shutdown_command = var.vagrant_shutdown_command
ssh_username = var.vagrant_ssh_username
ssh_password = var.vagrant_ssh_password
ssh_timeout = var.ssh_timeout
boot_command = var.vagrant_boot_command_8_x86_64_bios
boot_wait = var.boot_wait
cpus = var.cpus
disk_size = var.vagrant_disk_size
guest_os_type = "centos"
memory = var.memory
parallels_tools_flavor = var.parallels_tools_flavor_x86_64
}
build {
sources = [
"source.qemu.almalinux-8",
"source.virtualbox-iso.almalinux-8",
"source.hyperv-iso.almalinux-8",
"source.vmware-iso.almalinux-8",
"source.parallels-iso.almalinux-8",
]
provisioner "ansible" {
galaxy_file = "./ansible/requirements.yml"
galaxy_force_install = true
collections_path = "./ansible/collections"
roles_path = "./ansible/roles"
playbook_file = "./ansible/vagrant-box.yml"
ansible_env_vars = [
"ANSIBLE_PIPELINING=True",
"ANSIBLE_REMOTE_TEMP=/tmp",
"ANSIBLE_SCP_EXTRA_ARGS=-O",
]
extra_arguments = [
"--extra-vars",
"packer_provider=${source.type} is_unified_boot=true",
]
only = [
"qemu.almalinux-8",
"virtualbox-iso.almalinux-8",
]
}
provisioner "ansible" {
user = "vagrant"
use_proxy = false
galaxy_file = "./ansible/requirements.yml"
galaxy_force_install = true
collections_path = "./ansible/collections"
roles_path = "./ansible/roles"
playbook_file = "./ansible/vagrant-box.yml"
ansible_env_vars = [
"ANSIBLE_PIPELINING=True",
"ANSIBLE_REMOTE_TEMP=/tmp",
"ANSIBLE_SCP_EXTRA_ARGS=-O",
"ANSIBLE_HOST_KEY_CHECKING=False",
]
extra_arguments = [
"--extra-vars",
"packer_provider=${source.type} ansible_ssh_pass=vagrant is_unified_boot=true",
]
only = ["hyperv-iso.almalinux-8"]
}
provisioner "shell" {
expect_disconnect = true
inline = ["sudo rm -fr /etc/ssh/*host*key*"]
only = ["hyperv-iso.almalinux-8"]
}
provisioner "ansible" {
galaxy_file = "./ansible/requirements.yml"
galaxy_force_install = true
collections_path = "./ansible/collections"
roles_path = "./ansible/roles"
playbook_file = "./ansible/vagrant-box.yml"
ansible_env_vars = [
"ANSIBLE_PIPELINING=True",
"ANSIBLE_REMOTE_TEMP=/tmp",
"ANSIBLE_SCP_EXTRA_ARGS=-O",
]
extra_arguments = [
"--extra-vars",
"packer_provider=${source.type}",
]
only = [
"vmware-iso.almalinux-8",
"parallels-iso.almalinux-8",
]
}
post-processors {
post-processor "vagrant" {
compression_level = "9"
vagrantfile_template = "tpl/vagrant/vagrantfile-libvirt.rb"
output = "AlmaLinux-8-Vagrant-${var.os_ver_8}-${formatdate("YYYYMMDD", timestamp())}.x86_64.{{.Provider}}.box"
only = ["qemu.almalinux-8"]
}
post-processor "vagrant" {
compression_level = "9"
output = "AlmaLinux-8-Vagrant-${var.os_ver_8}-${formatdate("YYYYMMDD", timestamp())}.x86_64.{{.Provider}}.box"
only = [
"virtualbox-iso.almalinux-8",
"hyperv-iso.almalinux-8",
"vmware-iso.almalinux-8",
"parallels-iso.almalinux-8",
]
}
}
}