Check if pillar 'prometheus:exporters' exists before run state

According to the workflow in the pipeline, prometheus:exporters
is not mandatory state and should run only if the pillar exists.

Change-Id: Iac68b836d92e80846ae50a794496b5bf9c4de678
Reviewed-on: https://review.gerrithub.io/376726
Reviewed-by: Dennis Dmitriev <dis.xcom@gmail.com>
Tested-by: Dennis Dmitriev <dis.xcom@gmail.com>
diff --git a/tcp_tests/templates/cookieshape-mcp-ocata-dvr-vxlan/sl.yaml b/tcp_tests/templates/cookieshape-mcp-ocata-dvr-vxlan/sl.yaml
index d95e3d0..2693084 100644
--- a/tcp_tests/templates/cookieshape-mcp-ocata-dvr-vxlan/sl.yaml
+++ b/tcp_tests/templates/cookieshape-mcp-ocata-dvr-vxlan/sl.yaml
@@ -72,8 +72,11 @@
   retry: {count: 2, delay: 10}
   skip_fail: false
 
-- description: Configure Prometheus exporters
-  cmd: salt -C 'I@prometheus:exporters' state.sls prometheus
+- description: Configure Prometheus exporters, if pillar 'prometheus:exporters' exists on any server
+  cmd: |
+    if salt -C 'I@prometheus:exporters' match.pillar 'prometheus:exporters' ; then
+      salt -C 'I@prometheus:exporters' state.sls prometheus
+    fi
   node_name: {{ HOSTNAME_CFG01 }}
   retry: {count: 1, delay: 10}
   skip_fail: false
diff --git a/tcp_tests/templates/virtual-mcp-ocata-cicd/sl.yaml b/tcp_tests/templates/virtual-mcp-ocata-cicd/sl.yaml
index f3d07fc..5a60b38 100644
--- a/tcp_tests/templates/virtual-mcp-ocata-cicd/sl.yaml
+++ b/tcp_tests/templates/virtual-mcp-ocata-cicd/sl.yaml
@@ -54,7 +54,7 @@
   retry: {count: 1, delay: 10}
   skip_fail: false
 
-- description: Install Prometheus exporters, if pillar 'prometheus:exporters' exists on any server
+- description: Configure Prometheus exporters, if pillar 'prometheus:exporters' exists on any server
   cmd: |
     if salt -C 'I@prometheus:exporters' match.pillar 'prometheus:exporters' ; then
       salt -C 'I@prometheus:exporters' state.sls prometheus
@@ -64,8 +64,6 @@
   skip_fail: false
 
 
-
-
 # Elasticsearch
 - description: Waiting for Elasticsearch to come up in container...
   cmd: timeout 60 salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@elasticsearch:server' cmd.run
diff --git a/tcp_tests/templates/virtual-mcp-ocata-dvr/sl.yaml b/tcp_tests/templates/virtual-mcp-ocata-dvr/sl.yaml
index a3ddc87..b5d7bc5 100644
--- a/tcp_tests/templates/virtual-mcp-ocata-dvr/sl.yaml
+++ b/tcp_tests/templates/virtual-mcp-ocata-dvr/sl.yaml
@@ -72,8 +72,11 @@
   retry: {count: 2, delay: 10}
   skip_fail: false
 
-- description: Configure Prometheus exporters
-  cmd: salt -C 'I@prometheus:exporters' state.sls prometheus
+- description: Configure Prometheus exporters, if pillar 'prometheus:exporters' exists on any server
+  cmd: |
+    if salt -C 'I@prometheus:exporters' match.pillar 'prometheus:exporters' ; then
+      salt -C 'I@prometheus:exporters' state.sls prometheus
+    fi
   node_name: {{ HOSTNAME_CFG01 }}
   retry: {count: 1, delay: 10}
   skip_fail: false
diff --git a/tcp_tests/templates/virtual-mcp11-k8s-calico/sl.yaml b/tcp_tests/templates/virtual-mcp11-k8s-calico/sl.yaml
index 8309364..3369f63 100644
--- a/tcp_tests/templates/virtual-mcp11-k8s-calico/sl.yaml
+++ b/tcp_tests/templates/virtual-mcp11-k8s-calico/sl.yaml
@@ -56,8 +56,11 @@
   retry: {count: 2, delay: 10}
   skip_fail: false
 
-- description: Configure Prometheus exporters
-  cmd: salt -C 'I@prometheus:exporters' state.sls prometheus
+- description: Configure Prometheus exporters, if pillar 'prometheus:exporters' exists on any server
+  cmd: |
+    if salt -C 'I@prometheus:exporters' match.pillar 'prometheus:exporters' ; then
+      salt -C 'I@prometheus:exporters' state.sls prometheus
+    fi
   node_name: {{ HOSTNAME_CFG01 }}
   retry: {count: 1, delay: 10}
   skip_fail: false
diff --git a/tcp_tests/templates/virtual-mcp11-k8s-contrail/sl.yaml b/tcp_tests/templates/virtual-mcp11-k8s-contrail/sl.yaml
index b90797f..d277c56 100644
--- a/tcp_tests/templates/virtual-mcp11-k8s-contrail/sl.yaml
+++ b/tcp_tests/templates/virtual-mcp11-k8s-contrail/sl.yaml
@@ -56,8 +56,11 @@
   retry: {count: 2, delay: 10}
   skip_fail: false
 
-- description: Configure Prometheus exporters
-  cmd: salt -C 'I@prometheus:exporters' state.sls prometheus
+- description: Configure Prometheus exporters, if pillar 'prometheus:exporters' exists on any server
+  cmd: |
+    if salt -C 'I@prometheus:exporters' match.pillar 'prometheus:exporters' ; then
+      salt -C 'I@prometheus:exporters' state.sls prometheus
+    fi
   node_name: {{ HOSTNAME_CFG01 }}
   retry: {count: 1, delay: 10}
   skip_fail: false