{
    "variables": {
        "user": "slapos",
        "password": "slapos",
        "domain": "",
        "disk_size": "100",
        "name": "image",
        "custom_script": "scripts/empty.sh"
    },

    "builders":
    [
        {
            "name": "ubuntu-16.04-server-{{ user `disk_size`}}G-{{ user `name`}}",

            "type": "qemu",
            "format": "qcow2",
            "accelerator": "kvm",
            "disk_size": "{{ user `disk_size`}}000",
            "headless": true,

            "iso_url": "http://releases.ubuntu.com/16.04/ubuntu-16.04.2-server-amd64.iso",
            "iso_checksum": "2bce60d18248df9980612619ff0b34e6",
            "iso_checksum_type": "md5",

            "http_directory": "http",

            "ssh_username": "{{user `user`}}",
            "ssh_password": "{{user `password`}}",
            "ssh_wait_timeout": "1800s",
            "shutdown_command": "sudo systemctl poweroff",

            "boot_wait": "3s",
            "boot_command": [
                "<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>",
                "/install/vmlinuz ",
                "initrd=/install/initrd.gz ",
                "hostname={{ .Name }} ",
                "net.ifnames=0 ",
                "auto-install/enable=true ",
                "debconf/priority=critical ",
                "passwd/user-fullname={{user `user`}} ",
                "passwd/user-password-again={{user `password`}} ",
                "passwd/user-password={{user `password`}} ",
                "passwd/username={{user `user`}} ",
                "noapic ",
                "preseed/url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/preseed-ubuntu16.04.cfg ",
                "<enter>"
            ]
        }
    ],

    "provisioners": [
        {
            "type": "shell",
            "execute_command": "echo '{{user `password`}}' | {{.Vars}} sudo -E -S bash '{{.Path}}'",
            "scripts": [
                "scripts/update-ubuntu.sh",
                "scripts/packages-ubuntu.sh",
                "scripts/grub-ubuntu.sh",
                "{{ user `custom_script` }}"
            ]
        }
    ]
}

