Skip to content

Commit

Permalink
Merge pull request #438 from gibizer/non-standard-port
Browse files Browse the repository at this point in the history
[edpm_ssh_known_hosts]Support non standard ssh port
  • Loading branch information
openshift-ci[bot] authored Oct 12, 2023
2 parents 298c93a + 109670e commit 12963be
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
1 change: 1 addition & 0 deletions roles/edpm_ssh_known_hosts/molecule/default/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ provisioner:
allovercloud:
hosts:
instance:
ansible_port: 2222
canonical_hostname: centos.localdomain
ctlplane_hostname: centos.ctlplane.localdomain
ctlplane_ip: 10.0.0.1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@

def test_ssh_host_keys(host):
expected = [
'10.0.0.1,centos.ctlplane.localdomain,10.0.1.1,centos.internalapi.localdomain,centos.localdomain,instance* ssh-rsa AAAATESTRSA',
'10.0.0.1,centos.ctlplane.localdomain,10.0.1.1,centos.internalapi.localdomain,centos.localdomain,instance* ssh-ed25519 AAAATESTED',
'10.0.0.1,centos.ctlplane.localdomain,10.0.1.1,centos.internalapi.localdomain,centos.localdomain,instance* ecdsa-sha2-nistp256 AAAATESTECDSA',
'[10.0.0.1]:2222,[centos.ctlplane.localdomain]:2222,[10.0.1.1]:2222,[centos.internalapi.localdomain]:2222,[centos.localdomain]:2222,[instance*]:2222 ssh-rsa AAAATESTRSA',
'[10.0.0.1]:2222,[centos.ctlplane.localdomain]:2222,[10.0.1.1]:2222,[centos.internalapi.localdomain]:2222,[centos.localdomain]:2222,[instance*]:2222 ssh-ed25519 AAAATESTED',
'[10.0.0.1]:2222,[centos.ctlplane.localdomain]:2222,[10.0.1.1]:2222,[centos.internalapi.localdomain]:2222,[centos.localdomain]:2222,[instance*]:2222 ecdsa-sha2-nistp256 AAAATESTECDSA',
]

for line in expected:
Expand Down
7 changes: 7 additions & 0 deletions roles/edpm_ssh_known_hosts/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,13 @@
{% set _ = entries.append(hostdata['canonical_hostname']) %}
{% endif %}
{% set _ = entries.append(host ~ '*') %}
{% if 'ansible_port' in hostdata and hostdata['ansible_port']|int != 22 %}
{% set hosts = [] %}
{% for host in entries %}
{% set _ = hosts.append("[%s]:%s" % (host, hostdata['ansible_port']) ) %}
{% endfor %}
{% set entries = hosts %}
{% endif %}
{% set host = entries|unique|join(',') %}
{% for key, type in key_types.items() %}
{% if key in hostdata['ansible_facts'] %}
Expand Down

0 comments on commit 12963be

Please sign in to comment.