Skip to content

Instantly share code, notes, and snippets.

@darron
Last active August 29, 2015 14:21
Show Gist options
  • Save darron/40ea69cb4975252fa0bd to your computer and use it in GitHub Desktop.
Save darron/40ea69cb4975252fa0bd to your computer and use it in GitHub Desktop.
virtualbox-iso build
{
"variables": {
"chef_version": "12.0.3",
"packer_box_dir": "/home/packer/builds/"
},
"builders": [
{
"type": "virtualbox-iso",
"boot_command": [
"<esc><wait>",
"<esc><wait>",
"<enter><wait>",
"/install/vmlinuz<wait>",
" auto<wait>",
" console-setup/ask_detect=false<wait>",
" console-setup/layoutcode=us<wait>",
" console-setup/modelcode=pc105<wait>",
" debconf/frontend=noninteractive<wait>",
" debian-installer=en_US<wait>",
" fb=false<wait>",
" initrd=/install/initrd.gz<wait>",
" kbd-chooser/method=us<wait>",
" keyboard-configuration/layout=USA<wait>",
" keyboard-configuration/variant=USA<wait>",
" locale=en_US<wait>",
" netcfg/get_hostname=ubuntu-1204<wait>",
" netcfg/get_domain=vagrantup.com<wait>",
" noapic<wait>",
" preseed/url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/preseed.cfg<wait>",
" -- <wait>",
"<enter><wait>"
],
"boot_wait": "10s",
"disk_size": 40960,
"guest_os_type": "Ubuntu_64",
"http_directory": "packer/http",
"headless": "true",
"iso_url": "http://releases.ubuntu.com/12.04/ubuntu-12.04.5-server-amd64.iso",
"iso_checksum": "769474248a3897f4865817446f9a4a53",
"iso_checksum_type": "md5",
"ssh_username": "vagrant",
"ssh_password": "vagrant",
"ssh_port": 22,
"ssh_wait_timeout": "10000s",
"shutdown_command": "echo 'shutdown -P now' > /tmp/shutdown.sh; echo 'vagrant'|sudo -S sh '/tmp/shutdown.sh'",
"vboxmanage": [
[ "modifyvm", "{{.Name}}", "--memory", "4096" ],
[ "modifyvm", "{{.Name}}", "--cpus", "2" ]
]
}
],
"provisioners": [
{
"type": "shell",
"only": [
"virtualbox-iso"
],
"execute_command": "echo 'vagrant' | sudo -S sh '{{ .Path }}'",
"inline": [
"rm -rf /var/lib/apt/lists/*",
"apt-get update -y",
"apt-get install -y linux-headers-$(uname -r) build-essential dkms curl",
"apt-get clean",
"mount -o loop VBoxGuestAdditions.iso /media/cdrom",
"sh /media/cdrom/VBoxLinuxAdditions.run",
"umount /media/cdrom",
"mkdir ~/.ssh",
"wget -qO- https://raw.github.com/mitchellh/vagrant/master/keys/vagrant.pub >> ~/.ssh/authorized_keys",
"echo 'vagrant ALL=NOPASSWD:ALL' > /tmp/vagrant",
"chmod 0440 /tmp/vagrant",
"mv /tmp/vagrant /etc/sudoers.d/"
]
}
],
"post-processors": [
{
"type": "vagrant",
"output": "{{user `packer_box_dir` }}vagrant-{{timestamp}}-virtualbox.box",
"only": [
"virtualbox-iso"
]
}
]
}
# This file goes into packer/http/preseed.cfg
# https://www.packer.io/docs/builders/virtualbox-iso.html#http_directory
choose-mirror-bin mirror/http/proxy string
d-i base-installer/kernel/override-image string linux-server
d-i clock-setup/utc boolean true
d-i clock-setup/utc-auto boolean true
d-i finish-install/reboot_in_progress note
d-i grub-installer/only_debian boolean true
d-i grub-installer/with_other_os boolean true
d-i partman-auto-lvm/guided_size string max
d-i partman-auto/choose_recipe select atomic
d-i partman-auto/method string lvm
d-i partman-lvm/confirm boolean true
d-i partman-lvm/confirm boolean true
d-i partman-lvm/confirm_nooverwrite boolean true
d-i partman-lvm/device_remove_lvm boolean true
d-i partman/choose_partition select finish
d-i partman/confirm boolean true
d-i partman/confirm_nooverwrite boolean true
d-i partman/confirm_write_new_label boolean true
# Default user
d-i passwd/user-fullname string vagrant
d-i passwd/username string vagrant
d-i passwd/user-password password vagrant
d-i passwd/user-password-again password vagrant
d-i passwd/username string vagrant
# Minimum packages (see postinstall.sh)
d-i pkgsel/include string openssh-server
d-i pkgsel/install-language-support boolean false
d-i pkgsel/update-policy select none
d-i pkgsel/upgrade select none
d-i time/zone string UTC
d-i user-setup/allow-password-weak boolean true
d-i user-setup/encrypt-home boolean false
tasksel tasksel/first multiselect standard, ubuntu-server
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment