diff --git a/src/main/java/com/batix/rundeck/plugins/AnsibleResourceModelSource.java b/src/main/java/com/batix/rundeck/plugins/AnsibleResourceModelSource.java index 09052964..a8c62e6e 100644 --- a/src/main/java/com/batix/rundeck/plugins/AnsibleResourceModelSource.java +++ b/src/main/java/com/batix/rundeck/plugins/AnsibleResourceModelSource.java @@ -293,9 +293,21 @@ public INodeSet getNodes() throws ResourceModelSourceException { System.out.println("[warn] Problem getting the ansible_host attribute from node " + hostname); } + String port = root.get("inventory_hostname").getAsString(); + try { + if (root.has("ansible_port")) { + port = root.get("ansible_port").getAsString(); + } else { // fallback to default ssh port + port = "22"; + } + }catch(Exception ex){ + System.out.println("[warn] Problem getting the ansible_port attribute from node " + port); + } + String nodename = root.get("inventory_hostname").getAsString(); + String hostname_with_port = hostname + ":" + port; - node.setHostname(hostname); + node.setHostname(hostname_with_port); node.setNodename(nodename); String username = System.getProperty("user.name"); // TODO better default?