Use Galera for storing Grafana items

Change-Id: I37a05d86395f8c825c617fff7474cedc60ce6768
diff --git a/classes/cluster/virtual-mcp11-contrail/stacklight/server.yml b/classes/cluster/virtual-mcp11-contrail/stacklight/server.yml
index 5abf51c..c6c06c5 100755
--- a/classes/cluster/virtual-mcp11-contrail/stacklight/server.yml
+++ b/classes/cluster/virtual-mcp11-contrail/stacklight/server.yml
@@ -42,6 +42,9 @@
     cluster_node03_hostname: mon03
     cluster_node03_address: ${_param:stacklight_monitor_node03_address}
     grafana_admin_password: admin
+    grafana_database_type: mysql
+    grafana_database_host: ${_param:openstack_database_address}
+    grafana_database_password: ${_param:mysql_grafana_password}
     docker_image_alertmanager: mirantis/alertmanager:latest
     docker_image_pushgateway: mirantis/pushgateway:latest
     docker_image_prometheus: mirantis/prometheus:latest
diff --git a/classes/cluster/virtual-mcp11-dvr/stacklight/server.yml b/classes/cluster/virtual-mcp11-dvr/stacklight/server.yml
index d49442a..fe157f8 100644
--- a/classes/cluster/virtual-mcp11-dvr/stacklight/server.yml
+++ b/classes/cluster/virtual-mcp11-dvr/stacklight/server.yml
@@ -42,6 +42,9 @@
     cluster_node03_hostname: mon03
     cluster_node03_address: ${_param:stacklight_monitor_node03_address}
     grafana_admin_password: admin
+    grafana_database_type: mysql
+    grafana_database_host: ${_param:openstack_database_address}
+    grafana_database_password: ${_param:mysql_grafana_password}
     docker_image_alertmanager: mirantis/alertmanager:latest
     docker_image_pushgateway: mirantis/pushgateway:latest
     docker_image_prometheus: mirantis/prometheus:latest
diff --git a/classes/cluster/virtual-mcp11-k8s-contrail/infra/config.yml b/classes/cluster/virtual-mcp11-k8s-contrail/infra/config.yml
index 4077b40..4fd9100 100644
--- a/classes/cluster/virtual-mcp11-k8s-contrail/infra/config.yml
+++ b/classes/cluster/virtual-mcp11-k8s-contrail/infra/config.yml
@@ -53,6 +53,7 @@
           name: ${_param:stacklight_node01_hostname}
           domain: ${_param:cluster_domain}
           classes:
+          - service.galera.master.cluster
           - system.docker.swarm.master
           - cluster.${_param:cluster_name}.stacklight.client
           - cluster.${_param:cluster_name}.stacklight.server
@@ -61,10 +62,12 @@
             linux_system_codename: xenial
             single_address: ${_param:stacklight_node01_address}
             keepalived_vip_priority: 100
+            mysql_cluster_role: master
         stacklight_node02:
           name: ${_param:stacklight_node02_hostname}
           domain: ${_param:cluster_domain}
           classes:
+          - service.galera.slave.cluster
           - system.docker.swarm.manager
           - cluster.${_param:cluster_name}.stacklight.server
           params:
@@ -72,10 +75,12 @@
             linux_system_codename: xenial
             single_address: ${_param:stacklight_node02_address}
             keepalived_vip_priority: 101
+            mysql_cluster_role: slave
         stacklight_node03:
           name: ${_param:stacklight_node03_hostname}
           domain: ${_param:cluster_domain}
           classes:
+          - service.galera.slave.cluster
           - system.docker.swarm.manager
           - cluster.${_param:cluster_name}.stacklight.server
           params:
@@ -83,6 +88,7 @@
             linux_system_codename: xenial
             single_address: ${_param:stacklight_node03_address}
             keepalived_vip_priority: 102
+            mysql_cluster_role: slave
         opencontrail_control_node01:
           params:
             rabbitmq_cluster_role: master
diff --git a/classes/cluster/virtual-mcp11-k8s-contrail/stacklight/init.yml b/classes/cluster/virtual-mcp11-k8s-contrail/stacklight/init.yml
index fcba2a5..3685807 100644
--- a/classes/cluster/virtual-mcp11-k8s-contrail/stacklight/init.yml
+++ b/classes/cluster/virtual-mcp11-k8s-contrail/stacklight/init.yml
@@ -11,6 +11,15 @@
     glusterfs_service_host: ${_param:stacklight_monitor_address}
     # Prometheus
     prometheus_control_address: ${_param:stacklight_monitor_address}
+
+    mysql_admin_user: root
+    mysql_admin_password: workshop
+
+    mysql_grafana_password: password
+    cluster_local_address: ${_param:single_address}
+    galera_server_cluster_name: monitoring_cluster
+    galera_server_maintenance_password: workshop
+    galera_server_admin_password: workshop
   linux:
     network:
       host:
diff --git a/classes/cluster/virtual-mcp11-k8s-contrail/stacklight/server.yml b/classes/cluster/virtual-mcp11-k8s-contrail/stacklight/server.yml
index d3be389..70a322c 100644
--- a/classes/cluster/virtual-mcp11-k8s-contrail/stacklight/server.yml
+++ b/classes/cluster/virtual-mcp11-k8s-contrail/stacklight/server.yml
@@ -1,6 +1,8 @@
 classes:
 - system.linux.system.repo.influxdb
 - system.linux.system.repo.tcp_elastic
+# Needed to install Galera packages
+- system.linux.system.repo.mcp.openstack
 - system.docker.host
 - system.elasticsearch.server.cluster
 - system.elasticsearch.server.curator
@@ -9,6 +11,8 @@
 - system.haproxy.proxy.listen.stacklight.kibana
 - system.haproxy.proxy.listen.stacklight.influxdb
 - service.haproxy.proxy.single
+- system.galera.server.cluster
+- system.galera.server.database.grafana
 - system.glusterfs.client.cluster
 - system.glusterfs.client.volume.prometheus
 - system.glusterfs.server.cluster
@@ -39,6 +43,12 @@
     keepalived_prometheus_vip_address: ${_param:cluster_vip_address}
     keepalived_prometheus_vip_password: password
     keepalived_prometheus_vip_interface: ens4
+    # Galera
+    openstack_version: newton
+    # Grafana
+    grafana_database_type: mysql
+    grafana_database_host: ${_param:cluster_vip_address}
+    grafana_database_password: ${_param:mysql_grafana_password}
     # Kibana
     kibana_elasticsearch_host: ${_param:cluster_vip_address}
     # Docker/Elasticsearch
@@ -55,3 +65,8 @@
     prometheus_influxdb_db: lma
     prometheus_influxdb_username: lma
     prometheus_influxdb_password: ${_param:influxdb_stacklight_password}
+  keepalived:
+    cluster:
+      instance:
+        VIP:
+          enabled: false