feat: add access to create/edit dashboards/visualizations

master
Sven Ketelsen 4 years ago
parent 19fa1db9c8
commit 56f7859314

@ -91,15 +91,17 @@
- base: []
feature:
advancedSettings:
- read
- all
dashboard:
- read
- all
discover:
- read
- all
indexPatterns:
- read
- all
savedObjectsManagement:
- read
- all
visualize:
- all
spaces:
- '{{ stage }}-{{ tenant_id }}'
elastic_spaces:
@ -127,10 +129,11 @@
- osquery
- savedObjectsTagging
es_index_pattern_tenant: '{{ stage }}-{{ tenant_id }}-{{ cluster_name }}-*'
es_index_pattern_service: '{{ stage }}-{{ tenant_id }}-{{ cluster_name }}-*-{{ cluster_service }}-*'
es_search_name: '{{ stage }}-{{ tenant_id }}-{{ cluster_name }}-{{ cluster_service }}'
es_dashboard_name: '{{ stage }}-{{ tenant_id }}-{{ cluster_name }}-{{ cluster_service }}'
es_container_name: '{{ stage }}-{{ tenant_id }}-{{ cluster_name }}-01-{{ cluster_service }}'
es_index_pattern_services:
- id: "{{ stage }}-{{ tenant_id }}-{{ cluster_name }}-*-{{ cluster_service }}-*"
name: "{{ cluster_service }}"
# - id: "{{ stage }}-{{ tenant_id }}-{{ cluster_name }}-*-dyns-*"
# name: "dyns"
tasks:
- name: "Do some stuff in elastic with spaces ... "
@ -183,27 +186,10 @@
es_space: *es_space_name
es_indexpattern_title: '{{ es_indexpattern_name }}'
es_index_pattern_tenant_uuid: '{{ es_index_pattern_tenant | to_uuid }}'
es_index_pattern_service_uuid: '{{ es_index_pattern_service | to_uuid }}'
es_search_title: '{{ es_search_name }}'
es_search_uuid: '{{ es_search_name | to_uuid }}'
es_panel_uuid: "{{ 'panel_' + es_dashboard_name | to_uuid }}"
es_dashboard_title: '{{ es_dashboard_name }}'
es_dashboard_uuid: '{{ es_dashboard_name | to_uuid }}'
tags:
- es-importobjects
#############################################################
# Sending smardigo management message to process
#############################################################
- hosts: "{{ stage }}-smardigo-management-message"
serial: "{{ serial_number | default(1) }}"
gather_facts: false
connection: local
run_once: true
vars:
connect_jwt_username: "{{ management_admin_username }}"
tasks:
- name: "Sending smardigo management message to <{{ smardigo_management_url }}>"
include_tasks: tasks/smardigo_management_message.yml

@ -0,0 +1,10 @@
$ANSIBLE_VAULT;1.1;AES256
66633636623163626238643266353032383361336339323638643731323632656131306564313265
6330396138646135393933633833633233323966363964630a323137353836373162303633646233
39653139623332393135666164623130613034303830353531616163656365366530386539323635
3263356465643137660a656534633536376364343764366261393862383765623261343532646632
62613234356633323737363763613234366338363061353964353866666530313463366138333161
33303037313831363033646364303133373334643533303436346364346561623762663864636636
30616634663464373236643036326461383964633833313430636639633339356335363838653530
36333430656235386664313932353764346537616534356366323462326435313165626664663335
6132

@ -1,61 +1,15 @@
---
- set_fact:
api_path: '/s/{{ es_space }}/api/saved_objects'
- name: "Importing kibana objects to <{{ api_endpoint }}>"
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: "Import smardigo default dashboard and its related objects (index-pattern,search,...)"
delegate_to: localhost
set_fact:
es_object_smardigo_index_pattern_tenant: "{{ lookup('template','smardigo_index_pattern_tenant.json.j2') }}"
es_object_smardigo_index_pattern_service: "{{ lookup('template','smardigo_index_pattern_service.json.j2') }}"
es_object_smardigo_search: "{{ lookup('template','smardigo_search.json.j2') }}"
es_object_smardigo_dashboard: "{{ lookup('template','smardigo_dashboard.json.j2') }}"
when:
- elastic_state == 'present'
- name: "Print objects to local file"
delegate_to: localhost
copy:
dest: '/tmp/es_objects_ready_to_import__objects.ndjson'
content: |
{{ es_object_smardigo_index_pattern_tenant | to_json(separators=(',',':')) }}
{{ es_object_smardigo_index_pattern_service | to_json(separators=(',',':')) }}
{{ es_object_smardigo_search | to_json(separators=(',',':')) }}
{{ es_object_smardigo_dashboard | to_json(separators=(',',':')) }}
when:
- elastic_state == 'present'
- name: "Import elastic objects ..."
delegate_to: localhost
uri:
url: "https://{{ api_endpoint }}{{ api_path }}/_import?overwrite=true"
method: POST
status_code: [200]
user: "{{ elastic_admin_username_vault }}"
password: "{{ elastic_admin_password_vault }}"
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: "Remove temporarily created file"
delegate_to: localhost
file:
state: absent
path: '/tmp/es_objects_ready_to_import__objects.ndjson'
when:
- elastic_state == 'present'
- name: "Set default indexpattern ..."
- name: "Setting default index pattern"
delegate_to: localhost
uri:
url: "https://{{ api_endpoint }}/s/dev-fgrz/api/kibana/settings"
url: "https://{{ api_endpoint }}/s/{{ stage }}-{{ tenant_id }}/api/kibana/settings"
method: POST
status_code: [200]
user: "{{ elastic_admin_username_vault }}"

@ -0,0 +1,56 @@
---
- set_fact:
api_path: '/s/{{ es_space }}/api/saved_objects'
es_search_name: '{{ stage }}-{{ tenant_id }}-{{ cluster_name }}-{{ es_index_pattern_service.name }}'
es_dashboard_name: '{{ stage }}-{{ tenant_id }}-{{ cluster_name }}-{{ es_index_pattern_service.name }}'
es_container_name: '{{ stage }}-{{ tenant_id }}-{{ cluster_name }}-01-{{ es_index_pattern_service.name }}'
- name: "Import smardigo default dashboard and its related objects (index-pattern,search,...)"
delegate_to: localhost
set_fact:
es_object_smardigo_index_pattern_tenant: "{{ lookup('template','smardigo_index_pattern_tenant.json.j2') }}"
es_object_smardigo_index_pattern_service: "{{ lookup('template','smardigo_index_pattern_service.json.j2') }}"
es_object_smardigo_search: "{{ lookup('template','smardigo_search.json.j2') }}"
es_object_smardigo_dashboard: "{{ lookup('template','smardigo_dashboard.json.j2') }}"
when:
- elastic_state == 'present'
- name: "Print objects to local file"
delegate_to: localhost
copy:
dest: '/tmp/es_objects_ready_to_import__objects.ndjson'
content: |
{{ es_object_smardigo_index_pattern_tenant | to_json(separators=(',',':')) }}
{{ es_object_smardigo_index_pattern_service | to_json(separators=(',',':')) }}
{{ es_object_smardigo_search | to_json(separators=(',',':')) }}
{{ es_object_smardigo_dashboard | to_json(separators=(',',':')) }}
when:
- elastic_state == 'present'
- name: "Import elastic objects ..."
delegate_to: localhost
uri:
url: "https://{{ api_endpoint }}{{ api_path }}/_import?overwrite=true"
method: POST
status_code: [200]
user: "{{ elastic_admin_username_vault }}"
password: "{{ elastic_admin_password_vault }}"
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: "Remove temporarily created file"
delegate_to: localhost
file:
state: absent
path: '/tmp/es_objects_ready_to_import__objects.ndjson'
when:
- elastic_state == 'present'

@ -8,16 +8,16 @@
"optionsJSON" : "{\"useMargins\":true,\"syncColors\":false,\"hidePanelTitles\":false}",
"panelsJSON" : "[{\"version\":\"7.16.1\",\"type\":\"search\",\"gridData\":{\"x\":0,\"y\":0,\"w\":50,\"h\":50,\"i\":\"{{ es_panel_uuid }}\"},\"panelIndex\":\"{{ es_panel_uuid }}\",\"embeddableConfig\":{\"enhancements\":{}},\"panelRefName\":\"panel_{{ es_panel_uuid }}\"}]",
"timeRestore" : false,
"title" : "{{ es_dashboard_title }}",
"title" : "{{ es_dashboard_name }}",
"version" : 1
},
"coreMigrationVersion" : "7.16.1",
"id" : "{{ es_dashboard_uuid }}",
"id" : "{{ es_dashboard_name | to_uuid }}",
"migrationVersion" : {
"dashboard" : "7.16.0"
},
"references" : [ {
"id" : "{{ es_search_uuid }}",
"id" : "{{ es_search_name | to_uuid }}",
"name" : "{{ es_panel_uuid }}:panel_{{ es_panel_uuid }}",
"type" : "search"
} ],

@ -4,11 +4,11 @@
"fields" : "[]",
"runtimeFieldMap" : "{}",
"timeFieldName" : "@timestamp",
"title" : "{{ es_index_pattern_service }}",
"title" : "{{ es_index_pattern_service.id }}",
"typeMeta" : "{}"
},
"coreMigrationVersion" : "7.16.1",
"id" : "{{ es_index_pattern_service_uuid }}",
"id" : "{{ es_index_pattern_service.id | to_uuid }}",
"migrationVersion" : {
"index-pattern" : "7.11.0"
},

@ -10,15 +10,15 @@
},
"sort" : [ [ "@timestamp",
"desc" ] ],
"title" : "{{ es_search_title }}"
"title" : "{{ es_search_name }}"
},
"coreMigrationVersion" : "7.16.1",
"id" : "{{ es_search_uuid }}",
"id" : "{{ es_search_name | to_uuid }}",
"migrationVersion" : {
"search" : "7.9.3"
},
"references" : [ {
"id" : "{{ es_index_pattern_service_uuid }}",
"id" : "{{ es_index_pattern_service.id | to_uuid }}",
"name" : "kibanaSavedObjectMeta.searchSourceJSON.index",
"type" : "index-pattern"
} ],

Loading…
Cancel
Save