|
|
---
|
|
|
- name: "Printing access_token for keycloak server"
|
|
|
debug:
|
|
|
msg:
|
|
|
- "{{ elastic_index_pattern }}"
|
|
|
|
|
|
- name: "Initializing service variables for <{{ elastic_index_pattern.name }}>"
|
|
|
set_fact:
|
|
|
api_path: '/s/{{ es_space }}/api/saved_objects'
|
|
|
elastic_search_name: "{{ elastic_index_pattern.search_name }}"
|
|
|
elastic_dashboard_name: "{{ elastic_index_pattern.dashboard_name }}"
|
|
|
elastic_index_pattern_uuid: "{{ elastic_index_pattern.id | to_uuid }}"
|
|
|
|
|
|
- name: "Importing smardigo default dashboard and its related objects (index-pattern,search,...)"
|
|
|
delegate_to: localhost
|
|
|
set_fact:
|
|
|
es_object_smardigo_search: "{{ lookup('template','smardigo_search.json.j2') }}"
|
|
|
es_object_smardigo_dashboard: "{{ lookup('template','smardigo_dashboard.json.j2') }}"
|
|
|
es_object_smardigo_index_pattern: "{{ lookup('template','smardigo_index_pattern.json.j2') }}"
|
|
|
when:
|
|
|
- elastic_state == 'present'
|
|
|
|
|
|
- name: "Printing service objects to local ndjson file"
|
|
|
delegate_to: localhost
|
|
|
copy:
|
|
|
dest: '/tmp/es_objects_ready_to_import__objects.ndjson'
|
|
|
mode: '0644'
|
|
|
content: |
|
|
|
{{ es_object_smardigo_search | to_json(separators=(',',':')) }}
|
|
|
{{ es_object_smardigo_dashboard | to_json(separators=(',',':')) }}
|
|
|
{{ es_object_smardigo_index_pattern | to_json(separators=(',',':')) }}
|
|
|
when:
|
|
|
- elastic_state == 'present'
|
|
|
|
|
|
- name: "Importing service objects to kibana"
|
|
|
delegate_to: localhost
|
|
|
uri:
|
|
|
url: "{{ shared_service_url_kibana }}{{ api_path }}/_import?overwrite=true"
|
|
|
method: POST
|
|
|
status_code: [200]
|
|
|
user: "{{ elastic_admin_username }}"
|
|
|
password: "{{ elastic_admin_password }}"
|
|
|
force_basic_auth: yes
|
|
|
headers:
|
|
|
kbn-xsrf: true
|
|
|
body_format: form-multipart
|
|
|
body:
|
|
|
file:
|
|
|
filename: '/tmp/es_objects_ready_to_import__objects.ndjson'
|
|
|
mime_type: 'application/octet-stream'
|
|
|
become: false
|
|
|
when:
|
|
|
- elastic_state == 'present'
|
|
|
|
|
|
- name: "Removing temporarily created file"
|
|
|
delegate_to: localhost
|
|
|
file:
|
|
|
state: absent
|
|
|
path: '/tmp/es_objects_ready_to_import__objects.ndjson'
|
|
|
when:
|
|
|
- elastic_state == 'present'
|