---
- name: Create and mount loop device
  hosts: build_host:&customization
  vars:
    - zoox_imaging_asset_type: robot_customization
  vars_files:
    - ../vars/customization.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: robot_customization
  vars_files:
    - ../vars/customization.yml
  roles:
    - { role: customization_directories, tags: customization_directories }
    # ssh_known_hosts should run BEFORE ssh_keys, since ssh_keys clears ~/.ssh/known_hosts
    - { role: ssh_known_hosts, tags: ssh_known_hosts }
    - { role: ssh_keys, tags: ssh_keys }
    - { role: ssh_authorized_keys, tags: ssh_authorized_keys }
    - { role: aws_credentials, tags: aws_credentials, when: not is_live_update }  # No live updates because this uses vault
    - { role: vehicle_aws_credentials, tags: vehicle_aws_credentials, when: not is_live_update }  # No live updates because this uses vault
    - { role: etc_hosts, tags: etc_hosts }
    - { role: misc_customization, tags: misc_customization }
    - { role: active_directory, tags: active_directory, when: not is_live_update }  # No live updates because this uses vault
    - { role: desktop_background, tags: desktop_background }
    - { 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: robot_customization
  vars_files:
    - ../vars/customization.yml
  tags:
    - unmount_and_gzip
  roles:
    - { role: unmount_loop, tags: unmount_loop }
    - { role: gzip_image, tags: gzip_image }
