- name: Set lab asset source paths
  set_fact:
    courseware_lab2_asset_src: "{{ playbook_dir }}/../../assets/lab2/wiki.test.raw"
    courseware_lab4_asset_src: "{{ playbook_dir }}/../../assets/lab4/ttps_dataset.parquet"

- name: Check lab 2 asset presence in repo
  stat:
    path: "{{ courseware_lab2_asset_src }}"
  register: courseware_lab2_asset

- name: Check lab 4 asset presence in repo
  stat:
    path: "{{ courseware_lab4_asset_src }}"
  register: courseware_lab4_asset

- name: Fail if required lab assets are missing from this checkout
  fail:
    msg: >-
      Required lab assets were not found in this repo checkout.
      Expected:
      {{ courseware_lab2_asset_src }}
      and
      {{ courseware_lab4_asset_src }}.
      Make sure the full project was copied, including the assets/ directory.
  when:
    - not courseware_lab2_asset.stat.exists or not courseware_lab4_asset.stat.exists

- name: Copy lab 2 wiki test corpus
  copy:
    src: "{{ courseware_lab2_asset_src }}"
    dest: "{{ courseware_datasets_dir }}/wiki.test.raw"
    mode: "0644"

- name: Render lab 2 WhiteRabbitNeo download helper
  template:
    src: "{{ playbook_dir }}/../templates/download_whiterabbitneo-gguf.sh.j2"
    dest: "{{ courseware_lab2_dir }}/download_whiterabbitneo-gguf.sh"
    mode: "0755"

- name: Copy lab 4 parquet dataset
  copy:
    src: "{{ courseware_lab4_asset_src }}"
    dest: "{{ courseware_datasets_dir }}/ttps_dataset.parquet"
    mode: "0644"
