Skip to content

Instantly share code, notes, and snippets.

@hyperfocus1338
Created July 11, 2014 14:39
Show Gist options
  • Save hyperfocus1338/fe1f3c557f8549d3385d to your computer and use it in GitHub Desktop.
Save hyperfocus1338/fe1f3c557f8549d3385d to your computer and use it in GitHub Desktop.
Packer Ansible and Shell provisioner example
{
"provisioners": [
{
"type": "shell",
"execute_command": "echo 'vagrant'|sudo -S sh '{{.Path}}'",
"script": "provision/shell/ansible.sh"
},
{
"type": "shell",
"scripts": [
"provision/shell/build_time.sh",
"provision/shell/apt.sh",
"provision/shell/sudo.sh",
"provision/shell/vagrant.sh",
"provision/shell/vbox.sh",
"provision/shell/cleanup.sh"
]},
{
"type": "ansible-local",
"playbook_file": "provision/ansible/main.yml"
},
],
"builders": [
{
"type": "virtualbox-iso",
"boot_command": [
"<esc><esc><enter><wait>",
"/install/vmlinuz noapic preseed/url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/preseed.cfg <wait>",
"debian-installer=en_US auto locale=en_US kbd-chooser/method=us <wait>",
"hostname={{ .Name }} <wait>",
"fb=false debconf/frontend=noninteractive <wait>",
"keyboard-configuration/modelcode=SKIP keyboard-configuration/layout=us keyboard-configuration/variant=us console-setup/ask_detect=false <wait>",
"initrd=/install/initrd.gz -- <enter><wait>"
],
"boot_wait": "10s",
"disk_size": 20480,
"guest_os_type": "Ubuntu_64",
"http_directory": "http",
"iso_checksum": "01545fa976c8367b4f0d59169ac4866c",
"iso_checksum_type": "md5",
"iso_url": "http://releases.ubuntu.com/14.04/ubuntu-14.04-server-amd64.iso",
"ssh_username": "vagrant",
"ssh_password": "vagrant",
"ssh_port": 22,
"ssh_wait_timeout": "10000s",
"shutdown_command": "echo 'shutdown -P now' > shutdown.sh; echo 'vagrant'|sudo -S sh 'shutdown.sh'",
"guest_additions_path": "VBoxGuestAdditions_{{.Version}}.iso",
"virtualbox_version_file": ".vbox_version",
"vm_name": "ubuntu-14.04-server-amd64",
"vboxmanage": [
[
"modifyvm",
"{{.Name}}",
"--memory",
"512"
],
[
"modifyvm",
"{{.Name}}",
"--cpus",
"1"
]
]
}
],
"post-processors": [
{
"output": "builds/ubuntu-14.04-server-amd64.box",
"type": "vagrant"
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment