---
- name: Installing service telemetry
  debug:
    msg: INSTALLING SERVICE TELEMETRY

# Default setup and platform querying
- name: Pre-setup
  include_tasks: pre.yml

# --> qdr
- name: Create QDR instance
  include_tasks: component_qdr.yml

# --> backends.metrics
- name: Create Prometheus instance
  include_tasks: component_prometheus.yml

# create Service Monitor instance
- name: Create Service Monitor instance
  include_tasks: component_servicemonitor.yml

# --> backends.events
- name: Deploy ElasticSearch events backend
  block:
  # TODO: check for availability of elasticsearches.elasticsearch.k8s.elastic.co to
  #       determine if we can create ElasticSearch and related certificates. Can't
  #       directly look up the CustomResourceDefinition because it requires ClusterRole scope.
  - name: Setup Certificates for ElasticSearch
    include_tasks: component_certificates.yml

  - name: Setup ElasticSearch
    include_tasks: component_elasticsearch.yml

# --> alerting
- name: Create Alertmanager instance
  include_tasks: component_alertmanager.yml

# --> graphing
- name: Deploy graphing
  block:
  - name: Create Grafana instance
    include_tasks: component_grafana.yml

# --> clouds
- name: Get data about clouds
  debug:
    var: servicetelemetry_vars.clouds

- name: Loop through cloud instances to setup transport receivers
  include_tasks: component_clouds.yml
  loop: "{{ servicetelemetry_vars.clouds }}"
  loop_control:
    loop_var: this_cloud

# Post deployment tasks
- name: Post-setup
  include_tasks: post.yml
