Skip to content

Instantly share code, notes, and snippets.

@bkw
Last active December 19, 2015 06:29
Show Gist options
  • Save bkw/5911407 to your computer and use it in GitHub Desktop.
Save bkw/5911407 to your computer and use it in GitHub Desktop.
packer.io config files to go from pristine vanilla ubuntu 12.04 LTS to a docker.io and chef-enabled vagrant box The resulting image is still a bit large and doesn't yet follow all the vagrant conventions, but it's a start.
d-i debian-installer/locale string en_US
d-i console-setup/ask_detect boolean false
d-i keyboard-configuration/modelcode string pc105
d-i netcfg/choose_interface select auto
d-i netcfg/get_hostname string unassigned-hostname
d-i netcfg/get_domain string unassigned-domain
d-i netcfg/wireless_wep string
d-i mirror/country string Germany
d-i mirror/http/mirror select de.archive.ubuntu.com
d-i mirror/http/hostname string de.archive.ubuntu.com
d-i mirror/http/directory string /ubuntu
d-i mirror/http/proxy string
d-i mirror/suite string precise
d-i clock-setup/utc boolean true
d-i time/zone string Europe/Berlin
d-i clock-setup/ntp boolean true
d-i partman-auto/init_automatically_partition select biggest_free
d-i partman-auto/disk string /dev/sda
d-i partman-auto/method string regular
#d-i partman-auto/choose_recipe select atomic
d-i partman/default_filesystem string ext4
d-i partman-partitioning/confirm_write_new_label 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/mount_style select label
#d-i base-installer/kernel/image string linux-generic
#d-i base-installer/kernel/image string linux-generic-lts-raring
d-i passwd/user-fullname string Ubuntu User
d-i passwd/username string ubuntu
d-i passwd/user-password password ubuntu
d-i passwd/user-password-again password ubuntu
d-i user-setup/allow-password-weak boolean true
d-i user-setup/encrypt-home boolean false
# Add docker repository:
d-i apt-setup/local0/repository string \
http://ppa.launchpad.net/dotcloud/lxc-docker/ubuntu precise main
d-i apt-setup/local0/comment string dotcloud-lxc-docker
d-i apt-setup/local0/source boolean true
d-i apt-setup/local0/key string \
http://keyserver.ubuntu.com:11371/pks/lookup?op=get&search=0xE61D797F63561DC6
tasksel tasksel/first multiselect standard
d-i pkgsel/include string openssh-server build-essential
d-i pkgsel/upgrade select full-upgrade
d-i pkgsel/install-language-support boolean false
# d-i pkgsel/language-packs multiselect en
# d-i pkgsel/update-policy select none
d-i pkgsel/update-policy select unattended-upgrades
d-i pkgsel/updatedb boolean true
d-i grub-installer/only_debian boolean true
d-i grub-installer/with_other_os boolean true
d-i finish-install/reboot_in_progress note
{
"builders": [
{
"type": "virtualbox",
"guest_os_type": "Ubuntu_64",
"iso_url": "http://releases.ubuntu.com/12.04/ubuntu-12.04.2-server-amd64.iso",
"iso_md5": "af5f788aee1b32c4b2634734309cc9e9",
"ssh_username": "ubuntu",
"ssh_password": "ubuntu",
"ssh_wait_timeout": "3000s",
"http_directory" : ".",
"boot_command" : [
"<esc><esc><enter><wait>",
"/install/vmlinuz noapic ",
"preseed/url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/preseed.cfg ",
"debian-installer=en_US auto locale=en_US kbd-chooser/method=de ",
"hostname={{ .Name }} ",
"fb=false debconf/frontend=noninteractive ",
"keyboard-configuration/modelcode=SKIP keyboard-configuration/layout=German ",
"keyboard-configuration/variant=German console-setup/ask_detect=false ",
"initrd=/install/initrd.gz -- <enter>"
]
}
],
"provisioners": [
{
"type": "shell",
"execute_command" : "echo 'ubuntu' | sudo -S sh '{{ .Path }}'",
"inline": [
"mkdir -m 0711 ~ubuntu/.ssh",
"echo 'ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+kz4TjGYe7gHzIw+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdOKLv6IedplqoPkcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4O7PtixWKn5y2hMNG0zQPyUecp4pzC6kivAIhyfHilFR61RGL+GPXQ2MWZWFYbAGjyiYJnAmCP3NOTd0jMZEnDkbUvxhMmBYSdETk1rRgm+R4LOzFUGaHqHDLKLX+FIPKcF96hrucXzcWyLbIbEgE98OHlnVYCzRdK8jlqm8tehUc9c9WhQ== vagrant insecure public key' > ~ubuntu/.ssh/authorized_keys",
"apt-get update",
"apt-get install -y build-essential dkms rubygems lxc-docker",
"mkdir /mnt/VBoxGuestAdditions",
"mount ~ubuntu/VBoxGuestAdditions.iso /mnt/VBoxGuestAdditions",
"sh /mnt/VBoxGuestAdditions/VBoxLinuxAdditions.run",
"apt-get dist-upgrade -y",
"apt-get clean",
"echo '%adm ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers",
"echo 'UseDNS no' >> /etc/ssh/sshd_config",
"gem install --no-rdoc --no-ri chef",
"umount /mnt/VBoxGuestAdditions",
"rmdir /mnt/VBoxGuestAdditions",
"rm ~ubuntu/VBoxGuestAdditions.iso",
"apt-get install -y linux-image-generic-lts-raring linux-headers-generic-lts-raring lxc-docker"
]
}
],
"post-processors": [
"vagrant"
]
}
@floodedcodeboy
Copy link

There are still a few issues with this script. Using it created a packaged box that vagrant could use however vagrant did not complete it's start up procedure and hung on " Waiting for VM to boot. This can take a few minutes. ". After killing the process i could use:

vagrant ssh -p -- -l ubuntu 

to login with the password.

I could not use:

vagrant halt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment