---
- name: "Importing kibana objects to <{{ shared_service_url_kibana }}>"
  include_tasks: import_service_ojects.yml
  loop: "{{ es_index_pattern_services }}"
  loop_control:
    label: "{{ es_index_pattern_service.id }}"
    loop_var: es_index_pattern_service

- name: "Setting default index pattern"
  delegate_to: localhost
  uri:
    url: "{{ shared_service_url_kibana }}/s/{{ stage }}-{{ tenant_id }}/api/kibana/settings"
    method: POST
    status_code: [200]
    user: "{{ elastic_admin_username }}"
    password: "{{ elastic_admin_password }}"
    force_basic_auth: yes
    headers:
      kbn-xsrf: true
    body_format: json
    body:
      changes:
        defaultIndex: '{{ es_index_pattern_tenant_uuid }}'
  become: false
  when:
    - elastic_state == 'present'
