Skip to content

Instantly share code, notes, and snippets.

@mhaligowski
Created July 6, 2018 05:34
Show Gist options
  • Save mhaligowski/1de7bb67d3128d3de80520329b7e7aed to your computer and use it in GitHub Desktop.
Save mhaligowski/1de7bb67d3128d3de80520329b7e7aed to your computer and use it in GitHub Desktop.
Prepare VirtualBox VM (+Vagrant) with WordPress preinstalled
{
"_comment": "Build with `packer build ubuntu.json`",
"builders": [
{
"boot_command": [
"{{ user `boot_command_prefix` }}",
"/install/vmlinuz noapic ",
"initrd=/install/initrd.gz ",
"file=/floppy/{{ user `preseed` }} ",
"debian-installer={{ user `locale` }} auto locale={{ user `locale` }} kbd-chooser/method=us ",
"hostname={{ user `hostname` }} ",
"grub-installer/bootdev=/dev/sda<wait> ",
"fb=false debconf/frontend=noninteractive ",
"keyboard-configuration/modelcode=SKIP keyboard-configuration/layout=USA ",
"keyboard-configuration/variant=USA console-setup/ask_detect=false ",
"passwd/user-fullname={{ user `ssh_fullname` }} ",
"passwd/user-password={{ user `ssh_password` }} ",
"passwd/user-password-again={{ user `ssh_password` }} ",
"passwd/username={{ user `ssh_username` }} ",
"-- <enter>"
],
"disk_size": "{{ user `disk_size` }}",
"floppy_files": [
"{{ user `preseed` }}"
],
"guest_additions_path": "VBoxGuestAdditions_{{.Version}}.iso",
"guest_os_type": "{{ user `virtualbox_guest_os_type` }}",
"hard_drive_interface": "sata",
"headless": "{{ user `headless` }}",
"iso_checksum": "{{ user `iso_checksum` }}",
"iso_checksum_type": "{{ user `iso_checksum_type` }}",
"iso_urls": [
"{{ user `iso_path` }}/{{ user `iso_name` }}",
"{{ user `iso_url` }}"
],
"output_directory": "output-{{ user `vm_name` }}-virtualbox-iso",
"post_shutdown_delay": "1m",
"shutdown_command": "echo '{{ user `ssh_password` }}' | sudo -S shutdown -P now",
"ssh_password": "{{ user `ssh_password` }}",
"ssh_username": "{{ user `ssh_username` }}",
"ssh_wait_timeout": "10000s",
"type": "virtualbox-iso",
"vboxmanage": [
[
"modifyvm",
"{{.Name}}",
"--nictype1",
"virtio"
],
[
"modifyvm",
"{{.Name}}",
"--memory",
"{{ user `memory` }}"
],
[
"modifyvm",
"{{.Name}}",
"--cpus",
"{{ user `cpus` }}"
]
],
"virtualbox_version_file": ".vbox_version",
"vm_name": "{{user `vm_name`}}"
}
],
"post-processors": [
{
"keep_input_artifact": true,
"output": "box/{{.Provider}}/{{user `vm_name`}}-{{user `version`}}.box",
"type": "vagrant",
"vagrantfile_template": "{{ user `vagrantfile_template` }}"
}
],
"provisioners": [
{
"environment_vars": [
"CLEANUP_PAUSE={{user `cleanup_pause`}}",
"DESKTOP={{user `desktop`}}",
"UPDATE={{user `update`}}",
"INSTALL_VAGRANT_KEY={{user `install_vagrant_key`}}",
"SSH_USERNAME={{user `ssh_username`}}",
"SSH_PASSWORD={{user `ssh_password`}}",
"DBPASSWORD_ADMIN={{user `database_root_password`}}",
"WORDPRESS_DB_USERNAME={{user `wordpress_database_user`}}",
"WORDPRESS_DB_PASSWORD={{user `wordpress_database_password`}}",
"WORDPRESS_DB_NAME={{user `wordpress_database_name`}}",
"WORDPRESS_SITE_NAME={{user `wordpress_title`}}",
"WORDPRESS_ADMIN_EMAIL={{user `wordpress_admin_email`}}",
"WORDPRESS_ADMIN_PASSWORD={{user `wordpress_admin_password`}}",
"WORDPRESS_ADMIN_USER={{user `wordpress_admin_name`}}",
"WORDPRESS_PLUGINS={{user `wordpress_plugins`}}",
"http_proxy={{user `http_proxy`}}",
"https_proxy={{user `https_proxy`}}",
"ftp_proxy={{user `ftp_proxy`}}",
"rsync_proxy={{user `rsync_proxy`}}",
"no_proxy={{user `no_proxy`}}"
],
"type": "shell",
"scripts": [
"./scripts/01_update.sh",
"./scripts/02_install_php.sh",
"./scripts/03_vagrant.sh",
"./scripts/04_virtualbox.sh",
"./scripts/05_mariadb.sh",
"./scripts/06_wordpress.sh"
],
"execute_command": "echo '{{ user `ssh_password` }}' | {{.Vars}} sudo -E -S bash '{{.Path}}'"
}
],
"variables": {
"boot_command_prefix": "<enter><wait><f6><esc><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs>",
"cleanup_pause": "",
"cpus": "1",
"custom_script": "custom-script.sh",
"desktop": "false",
"disk_size": "65536",
"ftp_proxy": "{{env `ftp_proxy`}}",
"headless": "true",
"http_proxy": "{{env `http_proxy`}}",
"https_proxy": "{{env `https_proxy`}}",
"install_vagrant_key": "true",
"iso_checksum": "70db69379816b91eb01559212ae474a36ecec9ef",
"iso_checksum_type": "sha1",
"iso_name": "ubuntu-16.04-server-amd64.iso",
"iso_path": "/Volumes/Storage/software/ubuntu",
"iso_url": "http://releases.ubuntu.com/16.04/ubuntu-16.04-server-amd64.iso",
"locale": "en_US",
"memory": "512",
"no_proxy": "{{env `no_proxy`}}",
"preseed": "preseed.cfg",
"rsync_proxy": "{{env `rsync_proxy`}}",
"hostname": "vagrant",
"ssh_fullname": "vagrant",
"ssh_password": "vagrant",
"ssh_username": "vagrant",
"database_root_password": "t00r",
"wordpress_database_user": "wordpress",
"wordpress_database_password": "sserpdrow",
"wordpress_database_name": "wordpress_db",
"wordpress_title": "Hello",
"wordpress_admin_name": "Admin",
"wordpress_admin_email": "mhaligowski@gmail.com",
"wordpress_admin_password": "q1w2e3r4",
"wordpress_plugins": "",
"update": "false",
"vagrantfile_template": "",
"version": "0.1.0",
"virtualbox_guest_os_type": "Ubuntu_64",
"vm_name": "ubuntu1604",
"vmware_guest_os_type": "ubuntu-64"
}
}
# Ubuntu preseed file - preseed.cfg
# Works for Ubuntu 10.x, 11.x & 12.x
#
# For more information on preseed syntax and commands, refer to:
# https://help.ubuntu.com/12.04/installation-guide/i386/appendix-preseed.html
#
# For testing, you can fire up a local http server temporary.
# Download the preseed.cfg file locally, cd to the directory where the
# preseed.cfg resides and run hte following command:
# $ python -m SimpleHTTPServer
# You don't have to restart the server every time you make changes. Python
# will reload the file from disk every time there is a request. As long as you
# save your changes they will be reflected in the next HTTP download. Then to
# test with a PXE boot server, use the following kernel boot parameters:
# > linux auto url=http://<your_ip>:8000/preseed.cfg hostname=<hostname> locale=en_US keyboard-configuration/modelcode=SKIP
#
# NOTE: If you netboot/PXE boot Ubuntu, it will ignore the value in hostname,
# but you must provide a hostname as a boot parameter to prevent the Ubuntu
# install from prompting for a hostname
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_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
d-i user-setup/allow-password-weak boolean true
d-i user-setup/encrypt-home boolean false
#d-i pkgsel/include string openssh-server cryptsetup build-essential libssl-dev libreadline-dev zlib1g-dev linux-source dkms
d-i pkgsel/include string openssh-server ntp curl nfs-common linux-headers-$(uname -r) build-essential perl dkms
d-i pkgsel/install-language-support boolean false
# Policy for applying updates. May be "none" (no automatic updates),
# "unattended-upgrades" (install security updates automatically), or
# "landscape" (manage system with Landscape).
d-i pkgsel/update-policy select none
d-i pkgsel/upgrade select full-upgrade
d-i time/zone string UTC
tasksel tasksel/first multiselect standard, server
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment