- name: Get Assets according to the platform
  import_tasks: get_istio_assets.yml

- name: Create a temp dir
  command: mktemp -d -t ansible.XXXXXXXXXX
  register: temp_output

- name: Download the asset
  get_url:
    url: "{{ asset_url }}"
    dest: "{{ temp_output.stdout }}/{{ asset_name }}"

- name: Unzip the archive
  command: "unzip {{ asset_name }} -d {{ istio.dest }}"
  args:
    chdir: "{{ temp_output.stdout }}"
  when: asset_name | search('zip')

- name: Untar the archive
  command: "tar -xvzf {{ asset_name }} -C {{ istio.dest }}"
  args:
    chdir: "{{ temp_output.stdout }}"
  when: asset_name | search('tar.gz')

- name: Remove the temp directory
  file:
    path: "{{ temp_output.stdout }}"
    state: absent