---
- name: helm.tar.gz copy
  copy:
    src: "{{ role_path }}/files/helm.tar.gz"
    dest: /root
  when:
    - inventory_hostname == groups['agent-master'][0]

- name: helm install
  unarchive:
    src: /root/helm.tar.gz
    dest: /usr/local/bin/
    remote_src: yes
  when:
    - inventory_hostname == groups['agent-master'][0]

- name: JSDP Clinet Chart copy
  copy:
    src: "{{ role_path }}/files/jspd-client"
    dest: /root/
  when:
    - inventory_hostname == groups['agent-master'][0]

- name: JSDP TPCC Chart copy
  copy:
    src: "{{ role_path }}/files/jspd-tpcc"
    dest: /root/
  when:
    - inventory_hostname == groups['agent-master'][0]

- name: Deploy JSPD Client
  kubernetes.core.helm:
    name: jspd-client
    chart_ref: "/root/jspd-client"
    release_namespace: "{{ NAMESAPCE }}"
    values:
      global:
        CLUSTER_ID: "{{ CLUSTER_ID }}"
        IMXC_IN_REGISTRY: "10.10.31.243:5000/cmoa3"
        DATAGATE: "{{ DATAGATE }}"
        DATAGATE_IP: "{{ DATAGATE_IP }}"
        DATAGATE_PORT: "30051"
        JSPD_LITE_COLLECTOR_NODEPORT: "40083"
        JSPD_LITE_COLLECTOR_VERSION: "rel{{ VERSION }}"
        TRACE_AGENT_VERSION: "rel{{ VERSION }}"
  when:
    - inventory_hostname == groups['agent-master'][0]

- name: Deploy JSPD TPCC
  kubernetes.core.helm:
    name: jspd-tpcc
    chart_ref: "/root/jspd-tpcc"
    release_namespace: "default"
    values:
      global:
        CLUSTER_ID: "{{ CLUSTER_ID }}"
        AGENT_NAMESPACE: "{{ NAMESAPCE }}"
        TPCC_NAMESPACE: "default"
        IMXC_IN_REGISTRY: "10.10.31.243:5000/cmoa3"
        POSTGRES_NODEPORT: "30002"
        POSTGRES_EXPORTER_NODEPORT: "30001"
  when:
    - inventory_hostname == groups['agent-master'][0]
