Skip to content

Commit

Permalink
Add support for setting ssh port
Browse files Browse the repository at this point in the history
Some systems run multiple ssh servers, for instance if they host SFTP servers. 
In that case its nice to be able to configure a different ssh port for rundeck to use on some EC2 instances.

Rundeck would like the ssh port to be part of the hostname like this <hostname>:<port>
Setting a sshport.selector will append that port to the hostname if its different from 22.
  • Loading branch information
Jesper Terkelsen committed Oct 9, 2015
1 parent 3ca31b5 commit 371194b
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ Here is the default mapping:
description.default=EC2 node instance
editUrl.default=https://console.aws.amazon.com/ec2/home#s=Instances&selectInstance=${node.instanceId}
hostname.selector=publicDnsName
sshport.default=22
sshport.selector=tags/ssh_config_Port
instanceId.selector=instanceId
nodename.selector=tags/Name,instanceId
osArch.selector=architecture
Expand Down Expand Up @@ -175,6 +177,7 @@ Rundeck nodes have the following metadata fields:

* `nodename` - unique identifier
* `hostname` - IP address/hostname to connect to the node
* `sshport` - The ssh port, if resolved to another port than 22 hostname will be set to ``<hostname>:<sshport>``
* `username` - SSH username to connect to the node
* `description` - textual description
* `osName` - OS name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ public class EC2ResourceModelSource implements ResourceModelSource {
static {
final String mapping = "nodename.selector=tags/Name,instanceId\n"
+ "hostname.selector=publicDnsName\n"
+ "sshport.default=22\n"
+ "sshport.selector=tags/ssh_config_Port\n"
+ "description.default=EC2 node instance\n"
+ "osArch.selector=architecture\n"
+ "osFamily.selector=platform\n"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,12 @@ static INodeEntry instanceToNode(final Instance inst, final Properties mapping)
}
node.setNodename(name);

// Set ssh port on hostname if not 22
String sshport = node.getAttributes().get("sshport");
if (sshport != null && !sshport.equals("") && !sshport.equals("22")) {
node.setHostname(node.getHostname() + ":" + sshport);
}

return node;
}

Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/defaultMapping.properties
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
description.default=EC2 node instance
editUrl.default=https://console.aws.amazon.com/ec2/home#Instances:search=${node.instanceId}
hostname.selector=publicDnsName
sshport.default=22
sshport.selector=tags/ssh_config_Port
instanceId.selector=instanceId
nodename.selector=tags/Name,instanceId
osArch.selector=architecture
Expand Down

0 comments on commit 371194b

Please sign in to comment.