---
- name: Build TensorFlow in Dual ABI container
  hosts: localhost
  vars_files:
    ../vars/vars.yml

  tasks:
    - name: Cleanup after previous build
      ansible.builtin.file:
        path: "{{ build_dir }}/{{ item }}"
        state: absent
      loop:
        - disk-cache
        - wheels
        - ml_wheels
        - tensorflow

    - name: Create cache dirs
      ansible.builtin.file:
        path: "{{ build_dir }}/{{ item }}"
        state: directory
        mode: 0777
      loop:
        - disk-cache
        - bazel-cache
        - wheels
        - ml_wheels

    - name: Go through each TensorFlow version
      ansible.builtin.include_role:
        name: tensorflow
        tasks_from: loop.yml
      loop: "{{ versions | dict2items }}"
      loop_control:
        loop_var: tf_ver
      when: tf_ver.key in to_be_built
