---

- name: Is istio.addon be iterable
  set_fact:
    is_istioaddon_iterable: "{{ istio.addon is defined and istio.addon is iterable }}"

- include_tasks: set_appropriate_cmd_path.yml
  when: cmd_path is not defined

- name: Extract server version
  shell: |
    {{ cmd_path }} version | sed -En "{{'s/kubernetes.*v([[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+).*/\1/p' if cluster_flavour == 'ocp' else 's/Server Version.*GitVersion.*v([[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+).*/\1/p'}}" | tail -1
  register: vo

- assert:
    that:
      - "vo.stdout is version_compare(minimum_cluster_version,'>=')"
    msg: "Cluster version must be at least {{ minimum_cluster_version }}"

- include_tasks: set_istio_path.yml

- include_tasks: delete_resources.yml
  when: istio.delete_resources == true

- include_tasks: install_on_cluster.yml

- include_tasks: change_scc.yml
  when: cluster_flavour == 'ocp'

- include_tasks: install_samples.yml
  when: (istio.samples is iterable) and (istio.samples | length > 0)
