Created
February 21, 2020 00:05
-
-
Save laurelmay/81bf6e470763b9e942e5479c573d98a6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
variable "vm_name" { | |
type = string | |
} | |
variable "semester" { | |
type = string | |
} | |
variable "mint_version" { | |
type = string | |
} | |
variable "build_id" { | |
default = "{{ isotime \"2006-01-02\" }}" | |
} | |
variable "git_repo" { | |
default = "https://github.com/jmunixusers/cs-vm-build" | |
} | |
variable "git_branch" { | |
default = "master" | |
} | |
variable "headless" { | |
default = true | |
} | |
variable "audio" { | |
default = "pulse" | |
} | |
variable "output_dir" { | |
default = "{{ pwd }}/artifacts" | |
} | |
variable "mirror_url" { | |
type = string | |
} | |
variable "iso_file" { | |
type = string | |
} | |
variable "ssh_user" { | |
default = "oem" | |
} | |
variable "ssh_pass" { | |
default = "oem" | |
} | |
source "virtualbox-iso" "cs-vm" { | |
headless = var.headless | |
http_directory = "http" | |
vm_name = "${var.vm_name} ${var.semester}" | |
cpus = 2 | |
memory = 4096 | |
sound = var.audio | |
vboxmanage = [ | |
["modifyvm", "{{.Name}}", "--clipboard-mode", "bidirectional" ], | |
["modifyvm", "{{.Name}}", "--graphicscontroller", "vmsvga" ], | |
["modifyvm", "{{.Name}}", "--mouse", "usbtablet"], | |
["modifyvm", "{{.Name}}", "--pae", "on"], | |
["modifyvm", "{{.Name}}", "--rtcuseutc", "on"], | |
["modifyvm", "{{.Name}}", "--usb", "on", "--usbehci", "off", "--usbxhci", "off" ], | |
["modifyvm", "{{.Name}}", "--vram", "64" ], | |
["modifyvm", "{{.Name}}", "--vrde", "off" ], | |
["storagectl", "{{.Name}}", "--name", "IDE Controller", "--remove" ], | |
["storagectl", "{{.Name}}", "--name", "SATA Controller", "--hostiocache", "on" ] | |
] | |
vboxmanage_post = [ | |
["modifyvm", "{{.Name}}", "--accelerate3d", "on" ], | |
["storageattach", "{{.Name}}", "--storagectl", "SATA Controller", | |
"--port", "1", "--type", "dvddrive", "--medium", "emptydrive"] | |
] | |
iso_url = "${var.mirror_url}/${var.iso_file}" | |
iso_checksum_type = "sha256" | |
iso_checksum_url = "${var.mirror_url}/sha256sum.txt" | |
iso_interface = "sata" | |
hard_drive_discard = true | |
hard_drive_interface = "sata" | |
hard_drive_nonrotational = true | |
sata_port_count = 2 | |
disk_size = 20480 | |
guest_os_type = "Ubuntu_64" | |
boot_wait = "5s" | |
boot_command = [ | |
"<esc><wait><esc><wait>", | |
"/casper/vmlinuz", | |
" auto url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/oem-preseed.cfg", | |
" automatic-ubiquity", | |
" debug-ubiquity", | |
" keymap=us", | |
" boot=casper initrd=/casper/initrd.lz quiet noprompt splash --", | |
"<enter>" | |
] | |
ssh_username = var.ssh_user | |
ssh_password = var.ssh_pass | |
ssh_timeout = "100m" | |
shutdown_command = "echo -e \"${var.ssh_pass}\\n\" | sudo -S poweroff" | |
output_directory = var.output_dir | |
format = "ova" | |
export_opts = [ | |
"--manifest", | |
"--vsys", "0", | |
"--description", "Build ID: ${var.build_id}", | |
"--product", "${var.vm_name} ${var.semester}", | |
"--producturl", "https://linuxmint.com/", | |
"--vendor", "JMU Unix Users Group", | |
"--vendorurl", "${var.git_repo}", | |
"--version", "${var.mint_version}" | |
] | |
} | |
build { | |
sources = [ | |
"source.virtualbox-iso.cs-vm" | |
] | |
provisioner "shell" { | |
execute_command = "echo 'oem' | sudo -S sh -c '{{ .Vars }} {{ .Path }}'" | |
inline = [ | |
"export DEBIAN_FRONTEND=noninteractive", | |
"apt-get update", | |
"apt-get install -y git ansible aptitude", | |
"git clone -b \"${var.git_branch}\" \"${var.git_repo}\"", | |
"cd /home/oem/cs-vm-build/scripts", | |
"./oem-build", | |
"/usr/sbin/oem-config-prepare" | |
] | |
} | |
post-processor "checksum" { | |
output = "${var.output_dir}/${var.vm_name} ${var.semester}.{{ .ChecksumType }}sum" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment