Fixed working with keys in salt print result

Change-Id: I53f4f65b0cc1596fe370207cd1894e55466d420d
diff --git a/src/com/mirantis/mk/Common.groovy b/src/com/mirantis/mk/Common.groovy
index 8c0b56e..0de056e 100644
--- a/src/com/mirantis/mk/Common.groovy
+++ b/src/com/mirantis/mk/Common.groovy
@@ -105,6 +105,23 @@
 }
 
 /**
+ * Print debug message, this message will show only if DEBUG global variable is present
+ * @param msg
+ * @param color Colorful output or not
+ */
+def debugMsg(msg, color = true){
+    def debugEnabled
+    try {
+        debugEnabled = DEBUG
+    } catch (MissingPropertyException e) {
+        debugEnabled = false
+    }
+    if(debugEnabled){
+        printMsg(msg, "red")
+    }
+}
+
+/**
  * Print message
  *
  * @param msg        Message to be printed
diff --git a/src/com/mirantis/mk/Salt.groovy b/src/com/mirantis/mk/Salt.groovy
index 7e56aad..d9e080f 100644
--- a/src/com/mirantis/mk/Salt.groovy
+++ b/src/com/mirantis/mk/Salt.groovy
@@ -313,12 +313,13 @@
                 out[nodeKey] = [:]
                 for (int k=0; k<node.size(); k++) {
                     def resource;
+                    def resKey;
                     if(node instanceof Map){
-                        def resKey = node.keySet()[k]
-                        resource = node[resKey]
+                        resKey = node.keySet()[k]
                     }else if(node instanceof List){
-                        resource = node[k]
+                        resKey=k
                     }
+                    resource = node[resKey]
                     if (resource instanceof String) {
                         //ORIGINAL??out[node.key] = node.value
                         out[nodeKey] = resource