# vim: set ft=yaml.ansible :
---
- name: Installing specific app
  shell: |
    override=''
    [[ -f /tmp/'{{ app_name }}.yaml' ]] && override='-f /tmp/{{ app_name }}.yaml' || true
    helm upgrade --install -n app "{{ app_name }}" -f app/{{ app_name }}.yaml ${override} ./app/openreplay --create-namespace
  args:
    executable: /bin/bash
  when: app_name|length > 0
  tags: app
- name: Installing OpenReplay core applications
  shell: |
    override=''
    [[ -f /tmp/'{{ item|basename }}' ]] && override='-f /tmp/{{ item|basename }}' || true
    helm upgrade --install -n app "{{ (item|basename).split ('.') | first }}" -f "{{ item }}" ${override} ./app/openreplay --create-namespace
  args:
    executable: /bin/bash
  with_fileglob:
    - "app/*.yaml"
  when: app_name|length == 0
  tags: apps

- name: getting kube dns ip
  shell: kubectl get service --namespace kube-system kube-dns -o jsonpath="{.spec.clusterIP}"
  register: kube_dns_ip
  tags: nginx
- name: Installing Proxy
  shell: |
    helm upgrade --install -n nginx-ingress nginx-ingress "./nginx-ingress/nginx-ingress" --create-namespace --set kubeDnsIP="{{ kube_dns_ip.stdout }}"
  tags: nginx
- name: Installing Monitoring
  shell: |
    helm upgrade --install -n monitoring monitoring "./monitoring/kube-prometheus-stack" -f "/tmp/monitoring.yaml" --create-namespace
  tags: monitoring
  when: enable_monitoring == "true"
