---
version: '3'

tasks:
  all:
    deps:
      - :install:software:kvm
      - :install:software:packer
      - :install:software:parallels
      - :install:software:virtualbox
      - :install:software:vmware
    desc: Build Packer images for all platforms (default setting uses `template.json`)
    summary: |
      # Build Packer images for all virtualization platforms

      This task begins by removing cached files that may interfere with the Packer build
      process. It then runs `packer build template.json` if no arguments are passed. This
      command will build Packer images for all the virtualization platforms specified in
      the template file. The template file may include instructions for the following
      virtualization platforms (and it is possible that it includes other ones that are
      not listed below):

      * Hyper-V
      * KVM
      * Parallels
      * VMWare
      * VirtualBox

      If you would like to build machine images with another template then you can pass the
      template's file name as a parameter (see example below).

      **Example building on all platforms:**
      `task build:all`

      **Example using a template file named `another_template.json`:**
      `task build:all -- another_template.json`
    log:
      error: Packer reported an error while running `packer build {{.TEMPLATE_FILE}}`
      start: Running `packer build {{.TEMPLATE_FILE}}`
      success: Packer finished building
    cmds:
      - packer build {{.TEMPLATE_FILE}}

  kvm:
    deps:
      - :install:software:kvm
      - :install:software:packer
    desc: Build a Packer image for KVM
    summary: |
      # Build a Packer image for KVM

      This task will build a machine image intended to be used by KVM environments. KVM
      environments are generally only available on Linux (although, it is supposedly
      possible to run KVM on macOS as well). By default, this task assumes the template
      file is titled `template.json` and that the file is in the root of the project. If
      you would like to use another template file then you can do so by passing the file
      name as a parameter (see example below).

      **Example:**
      `task build:kvm`

      **Example using a template file named `another_template.json`:**
      `task build:kvm -- another_template.json`
    log:
      error: Error running `packer build -only=qemu {{.TEMPLATE_FILE}}`
      start: Running `packer build -only=qemu {{.TEMPLATE_FILE}}`
      success: Successfully ran `packer build -only=qemu {{.TEMPLATE_FILE}}`
    cmds:
      - packer build -only=qemu {{.TEMPLATE_FILE}}

  parallels:
    deps:
      - :install:software:packer
      - :install:software:parallels
    desc: Build a Packer image for Parallels
    summary: |
      # Build a Packer image for Parallels

      This task will build a machine image intended to be used by Parallels. Parallels
      is only available for macOS. By default, this task assumes the template file is
      titled `template.json` and that the file is in the root of the project. If you
      would like to use another template file then you can do so by passing the file
      name as a parameter (see example below).

      **Example:**
      `task build:parallels`

      **Example using a template file named `another_template.json`:**
      `task build:parallels -- another_template.json`
    log:
      error: Error running `packer build -only=parallels-iso {{.TEMPLATE_FILE}}`
      start: Running `packer build -only=parallels-iso {{.TEMPLATE_FILE}}`
      success: Successfully ran `packer build -only=parallels-iso {{.TEMPLATE_FILE}}`
    cmds:
      - packer build -only=parallels-iso {{.TEMPLATE_FILE}}

  virtualbox:
    deps:
      - :install:software:packer
      - :install:software:virtualbox
    desc: Build a Packer image for VirtualBox
    summary: |
      # Build a Packer image for VirtualBox

      This task will build a machine image intended to be used by VirtualBox. By
      default, this task assumes the template file is titled `template.json` and
      that the file is in the root of the project. If you would like to use another
      template file then you can do so by passing the file name as a parameter
      (see example below).

      **Example:**
      `task build:virtualbox`

      **Example using a template file named `another_template.json`:**
      `task build:virtualbox -- another_template.json`
    log:
      error: Error running `packer build -only=virtualbox-iso {{.TEMPLATE_FILE}}`
      start: Running `packer build -only=virtualbox-iso {{.TEMPLATE_FILE}}`
      success: Successfully ran `packer build -only=virtualbox-iso {{.TEMPLATE_FILE}}`
    cmds:
      - packer build -only=virtualbox-iso {{.TEMPLATE_FILE}}

  vmware:
    deps:
      - :install:software:packer
      - :install:software:vmware
    desc: Build a Packer image for VMWare
    summary: |
      # Build a Packer image for VMWare

      This task will build a machine image intended to be used by VMWare. The image
      build can be used by either VMWare Workstation (i.e. Linux, Windows) or by
      VMWare Fusion (i.e. macOS). By default, this task assumes the template file is
      titled `template.json` and that the file is in the root of the project. If you
      would like to use another template file then you can do so by passing the file
      name as a parameter (see example below).

      **Example:**
      `task packer:vmware`

      **Example using a template file named `another_template.json`:**
      `task packer:vmware -- another_template.json`
    log:
      error: Error running `packer build -only=vmware-iso {{.TEMPLATE_FILE}}`
      start: Running `packer build -only=vmware-iso {{.TEMPLATE_FILE}}`
      success: Successfully ran `packer build -only=vmware-iso {{.TEMPLATE_FILE}}`
    cmds:
      - packer build -only=vmware-iso {{.TEMPLATE_FILE}}
