---
- name: Set up base image
  hosts: build_host:&tftpboot
  tags:
    - create_base
  vars_files:
    - ../vars/tftpboot.yml
  roles:
    - { role: create_loop_device, tags: create_loop_device }
    - { role: mount_loop, tags: mount_loop }
    - { role: debootstrap, tags: debootstrap }
    - { role: setup_chroot, tags: setup_chroot }

- name: Build tftpboot image
  hosts: chroot:live:&tftpboot
  vars_files:
    - ../vars/tftpboot.yml
    - ../vars/imaging_app.yml
    - ../vars/ubuntu_14_04.yml
  roles:
    - { role: apt_sources, tags: apt_sources }
    - { role: zoox_kernel, tags: zoox_kernel, when: not is_live_update }  # No live updates because we don't set up the chroot for live updates
    - { role: tftpboot, tags: tftpboot }
    - { role: zoox_os_build_metadata, asset_type: tftpboot, tags: zoox_os_build_metadata, when: not is_live_update }

- name: Finalize build
  hosts: build_host:&tftpboot
  tags:
    - finalize_build
  vars_files:
    - ../vars/tftpboot.yml
  roles:
    - { role: teardown_chroot, tags: teardown_chroot }
    - { role: unmount_loop, tags: unmount_loop }
    - { role: gzip_image, tags: gzip_image }
