Set the config Kibana document depending on the version
The patch allows to define the Kibana version within pillar
Change-Id: Ifa89a56e35ed6d9bedbec0a2d847a3b9c926b7e4
diff --git a/_states/kibana_object.py b/_states/kibana_object.py
index ca0a133..e8ac651 100644
--- a/_states/kibana_object.py
+++ b/_states/kibana_object.py
@@ -50,9 +50,7 @@
ret['comment'] = 'Content is not set'
return ret
- profile = __salt__['config.option']('kibana')
-
- url, index = _set_parameters(name, kibana_type, profile)
+ url, index = _get_parameters(name, kibana_type)
if not url:
ret['result'] = False
ret['comment'] = index
@@ -89,9 +87,7 @@
'''
ret = {'name': name, 'result': True, 'comment': '', 'changes': {}}
- profile = __salt__['config.option']('kibana')
-
- url, index = _set_parameters(name, kibana_type, profile)
+ url, index = _get_parameters(name, kibana_type)
if not url:
ret['result'] = False
ret['comment'] = index
@@ -116,7 +112,7 @@
return ret
-def _set_parameters(name, kibana_type, profile):
+def _get_parameters(name, kibana_type):
'''
Retrieve parameters from profile.
'''
@@ -124,6 +120,8 @@
if not kibana_type:
return False, 'Type is not set'
+ profile = __salt__['config.option']('kibana')
+
url = profile.get('kibana_url')
if not url:
return False, 'Cannot get URL needed by Kibana client'
diff --git a/kibana/client/init.sls b/kibana/client/init.sls
index a1f72b7..ee315f9 100644
--- a/kibana/client/init.sls
+++ b/kibana/client/init.sls
@@ -13,7 +13,7 @@
{%- else %}
kibana_object.absent:
{%- endif %}
- - name: {{ object_name }}
+ - name: {{ object.id|default(object_name) }}
- kibana_type: {{ object.type }}
{%- endfor %}
diff --git a/metadata/service/client.yml b/metadata/service/client.yml
index 2490bdb..e965def 100644
--- a/metadata/service/client.yml
+++ b/metadata/service/client.yml
@@ -1,11 +1,14 @@
applications:
- kibana
parameters:
+ _param:
+ kibana_version: 4.6.4
kibana:
client:
enabled: true
object:
- 'all':
+ config:
+ id: ${_param:kibana_version}
enabled: true
template: kibana/files/objects/config.json
type: 'config'
diff --git a/tests/pillar/kibana_client.sls b/tests/pillar/kibana_client.sls
new file mode 100644
index 0000000..4c742fb
--- /dev/null
+++ b/tests/pillar/kibana_client.sls
@@ -0,0 +1,13 @@
+kibana:
+ client:
+ enabled: true
+ object:
+ all:
+ id: 4.6.4
+ enabled: true
+ template: kibana/files/objects/config.json
+ type: config
+ logs:
+ enabled: true
+ template: kibana/files/objects/dashboard_logs.json
+ type: dashboard