|
|
|
|
@ -1,5 +1,6 @@
|
|
|
|
|
---
|
|
|
|
|
- set_fact:
|
|
|
|
|
- name: "Initialize VARs"
|
|
|
|
|
set_fact:
|
|
|
|
|
api_path: '/s/{{ es_space }}/api/saved_objects'
|
|
|
|
|
es_object_type: dashboard
|
|
|
|
|
dashboard_exists: False
|
|
|
|
|
@ -18,18 +19,21 @@
|
|
|
|
|
register: all_dashboards
|
|
|
|
|
become: false
|
|
|
|
|
|
|
|
|
|
- set_fact:
|
|
|
|
|
- name: "Lookup dashboard object"
|
|
|
|
|
set_fact:
|
|
|
|
|
lookup_dashboard_object: '{{ all_dashboards.json | community.general.json_query(querystr1) | first | community.general.json_query(dashboard_query) }}'
|
|
|
|
|
vars:
|
|
|
|
|
querystr1: "[saved_objects[*]]"
|
|
|
|
|
dashboard_query: "[?attributes.title=='{{ elastic_dashboard.attributes.title }}']"
|
|
|
|
|
|
|
|
|
|
- set_fact:
|
|
|
|
|
- name: "Set switch VAR"
|
|
|
|
|
set_fact:
|
|
|
|
|
dashboard_exists: True
|
|
|
|
|
when:
|
|
|
|
|
- lookup_dashboard_object | length > 0
|
|
|
|
|
|
|
|
|
|
- set_fact:
|
|
|
|
|
- name: "Drop not needed keys from dict"
|
|
|
|
|
set_fact:
|
|
|
|
|
elastic_dashboard_cleaned: "{{ elastic_dashboard_cleaned | combine( { item.key: item.value } ) }}"
|
|
|
|
|
with_dict: '{{ elastic_dashboard }}'
|
|
|
|
|
when:
|
|
|
|
|
@ -52,35 +56,40 @@
|
|
|
|
|
register: all_searches
|
|
|
|
|
become: false
|
|
|
|
|
|
|
|
|
|
- set_fact:
|
|
|
|
|
- name: "Lookup search object"
|
|
|
|
|
set_fact:
|
|
|
|
|
lookup_search_object: '{{ all_searches.json | community.general.json_query(querystr1) | first | community.general.json_query(search_query) }}'
|
|
|
|
|
vars:
|
|
|
|
|
querystr1: "[saved_objects[*]]"
|
|
|
|
|
search_query: "[?attributes.title=='{{ elastic_dashboard.references[0].search_refname }}']"
|
|
|
|
|
|
|
|
|
|
- set_fact:
|
|
|
|
|
- name: "Set switch VAR"
|
|
|
|
|
set_fact:
|
|
|
|
|
search_exists: True
|
|
|
|
|
when:
|
|
|
|
|
- lookup_search_object | length > 0
|
|
|
|
|
|
|
|
|
|
- debug:
|
|
|
|
|
- name: "DEBUG"
|
|
|
|
|
debug:
|
|
|
|
|
msg: 'lookup_search_object{{ lookup_search_object }}'
|
|
|
|
|
|
|
|
|
|
- set_fact:
|
|
|
|
|
- name: "Set VAR"
|
|
|
|
|
set_fact:
|
|
|
|
|
panelindex_uuid: '{{ elastic_dashboard.references[0].search_refname | to_uuid }}'
|
|
|
|
|
|
|
|
|
|
- name: "Doing evil string concatination with ansible in addition with variables"
|
|
|
|
|
delegate_to: localhost
|
|
|
|
|
set_fact:
|
|
|
|
|
panelsJSON: '{{ (''[{"version":"7.16.1","type":"search","gridData":{"x":0,"y":0,"w":48,"h":28,"i":"'' + ( panelindex_uuid | string ) + ''"},"panelIndex":"'' + ( panelindex_uuid | string ) + ''","embeddableConfig":{"enhancements":{}},"panelRefName":"panel_'' + ( panelindex_uuid | string ) + ''"}]'') | string }}'
|
|
|
|
|
panelsjson: '{{ (''[ { "version":"7.16.1","type":"search","gridData":{"x":0,"y":0,"w":48,"h":28,"i":"'' + ( panelindex_uuid | string ) + ''"},"panelIndex":"'' + ( panelindex_uuid | string ) + ''","embeddableConfig":{"enhancements":{} },"panelRefName":"panel_'' + ( panelindex_uuid | string ) + ''" } ]'') | string }}'
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
|
name: "Prepare step for merging dashboard objects"
|
|
|
|
|
delegate_to: localhost
|
|
|
|
|
set_fact:
|
|
|
|
|
ref_obj_modified:
|
|
|
|
|
attributes:
|
|
|
|
|
title: '{{ elastic_dashboard.attributes.title }}'
|
|
|
|
|
panelsJSON: '{{ panelsJSON | string }}'
|
|
|
|
|
panelsJSON: '{{ panelsjson | string }}'
|
|
|
|
|
references:
|
|
|
|
|
-
|
|
|
|
|
name: '{{ panelindex_uuid }}'
|
|
|
|
|
@ -105,7 +114,8 @@
|
|
|
|
|
set_fact:
|
|
|
|
|
elastic_dashboard_cleaned: "{{ elastic_dashboard_cleaned | combine( ref_obj_modified ) }}"
|
|
|
|
|
|
|
|
|
|
- debug:
|
|
|
|
|
- name: "DEBUG"
|
|
|
|
|
debug:
|
|
|
|
|
msg: 'DEBUG elastic_dashboard_cleaned: {{ elastic_dashboard_cleaned }}'
|
|
|
|
|
|
|
|
|
|
- name: "Create {{ es_object_type }} <<{{ elastic_dashboard.attributes.title }}>>"
|
|
|
|
|
|