Skip to content

Commit 9c8a00d

Browse files
committed
Removed Json unnecesary json node entry when gather facts is true
1 parent 89ca119 commit 9c8a00d

File tree

1 file changed

+3
-14
lines changed

1 file changed

+3
-14
lines changed

src/main/groovy/com/rundeck/plugins/ansible/plugin/AnsibleResourceModelSource.java

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -668,23 +668,12 @@ public void processWithGatherFacts(NodeSetImpl nodes, AnsibleRunner.AnsibleRunne
668668
}
669669

670670
if (hostVar.getValue() instanceof JsonPrimitive && ((JsonPrimitive) hostVar.getValue()).isString()) {
671-
String strValue = hostVar.getValue().getAsString();
672-
673-
if ((strValue.trim().startsWith("{") && strValue.trim().endsWith("}")) ||
674-
(strValue.trim().startsWith("[") && strValue.trim().endsWith("]"))) {
675-
try {
676-
JsonElement parsed = JsonParser.parseString(strValue);
677-
node.setAttribute(hostVar.getKey(), gson.toJson(parsed));
678-
} catch (Exception e) {
679-
node.setAttribute(hostVar.getKey(), strValue);
680-
}
681-
} else {
682-
node.setAttribute(hostVar.getKey(), strValue);
683-
}
671+
// Keep attribute as String, don't serialize as Json
672+
node.setAttribute(hostVar.getKey(), hostVar.getValue().getAsString());
684673
} else {
674+
// Serialize attribute as Json (JsonArray or JsonObject)
685675
node.setAttribute(hostVar.getKey(), gson.toJson(hostVar.getValue()));
686676
}
687-
688677
}
689678
}
690679

0 commit comments

Comments
 (0)