-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild.iso-full.pkr.hcl
73 lines (67 loc) · 3.01 KB
/
build.iso-full.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
build {
sources = ["source.vmware-iso.full"]
# Stage 0 - First Run Scripts
# This disables the welcome screen from the default user
provisioner "shell" {
inline = [
"mkdir -p /home/${var.username}/.config/",
"touch /home/${var.username}/.config/gnome-initial-setup-done",
]
}
# Stage 1 - Ubuntu Tweak Scripts
provisioner "shell" {
# Note: sudo -S env is necessary ot pass the environment variables down to each script
execute_command = "echo '${var.password}' | sudo -S env {{ .Vars }} {{ .Path }}"
environment_vars = local.script_environment_variables
scripts = [
"${path.root}/builtin_scripts/ubuntu/disable-aptdaily.sh",
"${path.root}/builtin_scripts/ubuntu/system-update.sh",
"${path.root}/builtin_scripts/ubuntu/open-vm-tools.sh",
"${path.root}/builtin_scripts/ubuntu/virtualbox-guest-x11.sh",
#"${path.root}/builtin_scripts/ubuntu/setup-saltstack.sh",
# Note: once https://github.com/hashicorp/packer/pull/10945 is merged, configure
# sudo becomes optional and or purely a user experience option
"${path.root}/builtin_scripts/ubuntu/configure-sudo.sh",
]
}
# Stage 3 - Custom Scripts
# This section is for scripts that are added custom to the packer build not included
# by the template, these can be anything that needs to happen to prepare the system
provisioner "shell" {
execute_command = "echo '${var.password}' | sudo -S -E bash '{{ .Path }}'"
scripts = [
"${path.root}/custom_scripts/nop.sh",
]
}
# Stage 4 - Saltstack
provisioner "shell" {
execute_command = "echo '${var.password}' | sudo -S -E bash '{{ .Path }}'"
scripts = [
"${path.root}/custom_scripts/cast-install.sh",
"${path.root}/custom_scripts/cast-sift.sh",
"${path.root}/custom_scripts/cast-clean.sh",
]
}
# Stage X - Sysprep Scripts (Part 2)
# Final Scripts, the last scripts that should be run.
provisioner "shell" {
execute_command = "echo '${var.password}' | sudo -S -E bash '{{ .Path }}'"
scripts = [
#"${path.root}/builtin_scripts/ubuntu/clean-saltstack.sh",
"${path.root}/builtin_scripts/virt-sysprep/sysprep-op-dhcp-client-state.sh",
"${path.root}/builtin_scripts/virt-sysprep/sysprep-op-logfiles.sh",
"${path.root}/builtin_scripts/virt-sysprep/sysprep-op-machine-id.sh",
"${path.root}/builtin_scripts/virt-sysprep/sysprep-op-network.sh",
"${path.root}/builtin_scripts/virt-sysprep/sysprep-op-package-manager-cache.sh",
"${path.root}/builtin_scripts/virt-sysprep/sysprep-op-ssh-hostkeys.sh",
"${path.root}/builtin_scripts/virt-sysprep/sysprep-op-tmp-files.sh",
"${path.root}/builtin_scripts/virt-sysprep/sysprep-op-disk-space.sh",
]
}
post-processors {
post-processor "shell-local" {
# || true so if there is an error it doesn't fail and clean up the built VM
inline = ["ovftool ${var.output_directory}/${var.name}-vmware-iso-full/${var.name}.vmx ${var.output_directory}/${var.name}-${local.timestamp}.ova || true"]
}
}
}