forked from AlmaLinux/cloud-images
-
Notifications
You must be signed in to change notification settings - Fork 0
/
almalinux-9-vagrant.pkr.hcl
204 lines (186 loc) · 6.32 KB
/
almalinux-9-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
/*
* AlmaLinux OS 9 Packer template for building Vagrant boxes.
*/
source "hyperv-iso" "almalinux-9" {
iso_url = var.iso_url_9_x86_64
iso_checksum = var.iso_checksum_9_x86_64
boot_command = var.vagrant_efi_boot_command_9_x86_64
boot_wait = var.boot_wait
generation = 2
switch_name = var.hyperv_switch_name
cpus = var.cpus
memory = var.memory
enable_dynamic_memory = true
disk_size = var.vagrant_disk_size
disk_block_size = 1
headless = var.headless
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
}
source "parallels-iso" "almalinux-9" {
boot_command = var.vagrant_boot_command_9_x86_64
boot_wait = var.boot_wait
cpus = var.cpus
disk_size = var.vagrant_disk_size
guest_os_type = "centos"
http_directory = var.http_directory
iso_checksum = var.iso_checksum_9_x86_64
iso_url = var.iso_url_9_x86_64
memory = var.memory
parallels_tools_flavor = var.parallels_tools_flavor_x86_64
shutdown_command = var.vagrant_shutdown_command
ssh_password = var.vagrant_ssh_password
ssh_timeout = var.ssh_timeout
ssh_username = var.vagrant_ssh_username
}
source "virtualbox-iso" "almalinux-9" {
iso_url = var.iso_url_9_x86_64
iso_checksum = var.iso_checksum_9_x86_64
boot_command = var.vagrant_boot_command_9_x86_64
boot_wait = var.boot_wait
cpus = var.cpus
memory = var.memory
disk_size = var.vagrant_disk_size
headless = var.headless
http_directory = var.http_directory
guest_os_type = "RedHat_64"
shutdown_command = var.vagrant_shutdown_command
ssh_username = var.vagrant_ssh_username
ssh_password = var.vagrant_ssh_password
ssh_timeout = var.ssh_timeout
hard_drive_interface = "sata"
vboxmanage_post = [
["modifyvm", "{{.Name}}", "--memory", var.post_memory],
["modifyvm", "{{.Name}}", "--cpus", var.post_cpus]
]
}
source "vmware-iso" "almalinux-9" {
iso_url = var.iso_url_9_x86_64
iso_checksum = var.iso_checksum_9_x86_64
boot_command = var.vagrant_boot_command_9_x86_64
boot_wait = var.boot_wait
cpus = var.cpus
memory = var.memory
disk_size = var.vagrant_disk_size
headless = var.headless
http_directory = var.http_directory
guest_os_type = "centos-64"
shutdown_command = var.vagrant_shutdown_command
ssh_username = var.vagrant_ssh_username
ssh_password = var.vagrant_ssh_password
ssh_timeout = var.ssh_timeout
vmx_data = {
"cpuid.coresPerSocket" : "1"
}
vmx_data_post = {
"memsize" : var.post_memory
"numvcpus" : var.post_cpus
}
vmx_remove_ethernet_interfaces = true
}
source "qemu" "almalinux-9" {
iso_checksum = var.iso_checksum_9_x86_64
iso_url = var.iso_url_9_x86_64
shutdown_command = var.vagrant_shutdown_command
accelerator = "kvm"
http_directory = var.http_directory
ssh_username = var.vagrant_ssh_username
ssh_password = var.vagrant_ssh_password
ssh_timeout = var.ssh_timeout
cpus = var.cpus
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-9"
boot_wait = var.boot_wait
boot_command = var.vagrant_boot_command_9_x86_64
qemuargs = [
["-cpu", "host"]
]
}
build {
sources = [
"sources.hyperv-iso.almalinux-9",
"sources.parallels-iso.almalinux-9",
"sources.virtualbox-iso.almalinux-9",
"sources.vmware-iso.almalinux-9",
"sources.qemu.almalinux-9"
]
provisioner "ansible" {
playbook_file = "./ansible/vagrant-box.yml"
galaxy_file = "./ansible/requirements.yml"
roles_path = "./ansible/roles"
collections_path = "./ansible/collections"
ansible_env_vars = [
"ANSIBLE_PIPELINING=True",
"ANSIBLE_REMOTE_TEMP=/tmp",
"ANSIBLE_SSH_ARGS='-o ControlMaster=no -o ControlPersist=180s -o ServerAliveInterval=120s -o TCPKeepAlive=yes'"
]
extra_arguments = [
"--extra-vars",
"packer_provider=${source.type}"
]
except = [
"hyperv-iso.almalinux-9"
]
}
provisioner "ansible" {
user = "vagrant"
use_proxy = false
playbook_file = "./ansible/vagrant-box.yml"
galaxy_file = "./ansible/requirements.yml"
roles_path = "./ansible/roles"
collections_path = "./ansible/collections"
ansible_env_vars = [
"ANSIBLE_PIPELINING=True",
"ANSIBLE_REMOTE_TEMP=/tmp",
"ANSIBLE_SSH_ARGS='-o ControlMaster=no -o ControlPersist=180s -o ServerAliveInterval=120s -o TCPKeepAlive=yes -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null'"
]
extra_arguments = [
"--extra-vars",
"packer_provider=${source.type} ansible_ssh_pass=vagrant"
]
only = [
"hyperv-iso.almalinux-9"
]
}
provisioner "shell" {
expect_disconnect = true
inline = [
"sudo rm -fr /etc/ssh/*host*key*"
]
only = [
"hyperv-iso.almalinux-9"
]
}
post-processors {
post-processor "vagrant" {
compression_level = "9"
output = "almalinux-9-x86_64.${formatdate("YYYYMMDD", timestamp())}.{{.Provider}}.box"
except = [
"qemu.almalinux-9"
]
}
post-processor "vagrant" {
compression_level = "9"
vagrantfile_template = "tpl/vagrant/vagrantfile-libvirt.tpl"
output = "almalinux-9-x86_64.${formatdate("YYYYMMDD", timestamp())}.{{.Provider}}.box"
only = [
"qemu.almalinux-9"
]
}
}
}