- name: Install Kiali
  block:

  - set_fact:
      kiali_version: istio-1.0

  - name: Install Kiali on Openshift
    shell: |
      curl https://raw.githubusercontent.com/kiali/kiali/{{ kiali_version }}/deploy/openshift/kiali-configmap.yaml | VERSION_LABEL={{ kiali_version }} envsubst | {{ cmd_path }} create -n {{ istio_namespace }} -f -
      curl https://raw.githubusercontent.com/kiali/kiali/{{ kiali_version }}/deploy/openshift/kiali-secrets.yaml | VERSION_LABEL={{ kiali_version }} envsubst | {{ cmd_path }} create -n {{ istio_namespace }} -f -
      curl https://raw.githubusercontent.com/kiali/kiali/{{ kiali_version }}/deploy/openshift/kiali.yaml | IMAGE_NAME=kiali/kiali IMAGE_VERSION={{ kiali_version }} NAMESPACE={{ istio_namespace }} VERSION_LABEL=master VERBOSE_MODE=4 envsubst | {{ cmd_path }} create -n {{ istio_namespace }} -f -
    when: "cluster_flavour == 'ocp'"

  - name: Install Kiali on Kubernetes
    shell: |
     curl https://raw.githubusercontent.com/kiali/kiali/{{ kiali_version }}/deploy/kubernetes/kiali-configmap.yaml | VERSION_LABEL={{ kiali_version }} envsubst | {{ cmd_path }} create -n {{ istio_namespace }} -f -
     curl https://raw.githubusercontent.com/kiali/kiali/{{ kiali_version }}/deploy/kubernetes/kiali-secrets.yaml | VERSION_LABEL={{ kiali_version }} envsubst | {{ cmd_path }} create -n {{ istio_namespace }} -f -
     curl https://raw.githubusercontent.com/kiali/kiali/{{ kiali_version }}/deploy/kubernetes/kiali.yaml | IMAGE_NAME=kiali/kiali IMAGE_VERSION={{ kiali_version }} NAMESPACE={{ istio_namespace }} VERSION_LABEL=master  VERBOSE_MODE=4 envsubst | {{ cmd_path }} create -n {{ istio_namespace }} -f -
    when: "cluster_flavour == 'k8s'"

  when:
    - is_istioaddon_iterable
    - "'kiali' in istio.addon"
