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

  "builders":
  [
    {
      "name": "debian8-{{ user `disk_size`}}G-{{ user `name`}}",

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

      "iso_url": "http://cdimage.debian.org/mirror/cdimage/archive/8.11.1/amd64/iso-cd/debian-8.11.1-amd64-netinst.iso",
      "iso_checksum": "df0ce86d0b1d81e232ad08eef58754ed",
      "iso_checksum_type": "md5",

      "http_directory": "http",

      "ssh_username": "{{user `user`}}",
      "ssh_password": "{{user `password`}}",
      "ssh_wait_timeout": "1800s",
      "shutdown_command": "echo '{{user `password`}}'|sudo -S shutdown -h now",

      "headless": true,
      "boot_wait": "2s",
      "boot_command": [
        "<esc><wait><wait>",
        "install auto ",
        "preseed/url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/preseed-debian8.cfg ",
        "debian-installer=en_US locale=en_US keymap=fr ",
        "netcfg/get_hostname={{ .Name }} ",
        "netcfg/get_domain={{ user `domain`}} ",

        "fb=false debconf/frontend=noninteractive ",

        "passwd/user-fullname={{user `user`}} ",
        "passwd/user-password={{user `password`}} ",
        "passwd/user-password-again={{user `password`}} ",
        "passwd/username={{user `user`}} ",

        "<enter>"
      ]
    }
  ],

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

