# Hosts:
# * build_host uses a local shell and is run for all build variants
# * chroot uses chroot into the target rootfs for all build variants
# * ai, vision, and operator also use chroot but only run for their particular build variants

---
- name: Create and mount loop device
  hosts: build_host:&customization
  vars:
    - zoox_imaging_asset_type: imaging_server_customization
  vars_files:
    - ../vars/customization.yml
    - ../vars/imaging_app.yml
  tags:
    - create_and_mount_loop
  roles:
    - { role: create_loop_device, tags: create_loop_device }
    - { role: mount_loop, tags: mount_loop }

- name: Create customization
  hosts: build_host:live:&customization
  vars:
    - zoox_imaging_asset_type: imaging_server_customization
  vars_files:
    - ../vars/customization.yml
    - ../vars/imaging_app.yml
    - ../vars/imaging_app.yml
  roles:
    - { role: customization_directories, tags: customization_directories }
    - { role: ssh_keys, tags: ssh_keys }
    - { role: ssh_authorized_keys, tags: ssh_authorized_keys }
    - { role: aws_credentials, tags: aws_credentials }
    - { role: misc_customization, tags: misc_customization }
    - { role: imaging_server_customization, tags: imaging_server_customization }
    - { role: zoox_os_build_metadata, asset_type: customization, tags: zoox_os_build_metadata, when: not is_live_update }

- name: Unmount and gzip image
  hosts: build_host:&customization
  vars:
    - zoox_imaging_asset_type: imaging_server_customization
  vars_files:
    - ../vars/customization.yml
    - ../vars/imaging_app.yml
  tags:
    - unmount_and_gzip
  roles:
    - { role: unmount_loop, tags: unmount_loop }
    - { role: gzip_image, tags: gzip_image }
