-
Notifications
You must be signed in to change notification settings - Fork 3
/
archlinux.pkr.hcl
57 lines (51 loc) · 1.62 KB
/
archlinux.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
packer {
required_plugins {
qemu = {
source = "github.com/hashicorp/qemu"
version = "~> 1"
}
ansible = {
source = "github.com/hashicorp/ansible"
version = "~> 1"
}
}
}
variable "username" {
type = string
}
source "qemu" "archlinux" {
accelerator = "kvm"
disk_image = true
disk_interface = "virtio"
format = "qcow2"
http_directory = "./http"
iso_checksum = "file:https://geo.mirror.pkgbuild.com/images/latest/Arch-Linux-x86_64-cloudimg.qcow2.SHA256"
iso_url = "https://geo.mirror.pkgbuild.com/images/latest/Arch-Linux-x86_64-cloudimg.qcow2"
net_device = "virtio-net"
shutdown_command = "sudo systemctl poweroff"
ssh_password = "archPassword"
ssh_timeout = "20m"
ssh_username = "${var.username}"
vm_name = "golden-arch.qcow2"
cd_files = ["cloud-init/meta-data", "cloud-init/user-data"]
cd_label = "cidata"
boot_wait = "30s"
boot_command = [
"${var.username}<enter>arch<enter>",
"arch<enter>archPassword<enter>archPassword<enter><wait>",
"curl -sfSLO http://{{ .HTTPIP }}:{{ .HTTPPort }}/pkglist.txt<enter><wait>"
]
}
build {
sources = ["source.qemu.archlinux"]
provisioner "shell" {
inline = ["sudo pacman -Sy ansible --noconfirm"]
}
provisioner "ansible-local" {
playbook_file = "./playbook.yml"
extra_arguments = ["--extra-vars", "'username=${var.username}'"]
}
provisioner "shell" {
inline = ["sudo usermod -p '!' ${var.username}"]
}
}