Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ansible hosts with non-standard ssh port #243

Open
tazmad opened this issue May 27, 2019 · 12 comments
Open

Ansible hosts with non-standard ssh port #243

tazmad opened this issue May 27, 2019 · 12 comments

Comments

@tazmad
Copy link

tazmad commented May 27, 2019

Hi there,

I'm trying to setup rundeck with ansible and so far I have been partially successful. The ansible hosts are correctly all detected and imported as nodes, however the hosts which are not using the standard port 22 for ssh have their port missing and I cannot see any option for specifying this.

I have tried setting the "extra ansible arguements" with "-e ansible_port=999", but this results in the job failing with the error "ERROR! the playbook: ansible_port=999 could not be found
23:08:23 Failed: AnsibleNonZero: ERROR: Ansible execution returned with non zero code."

Any help would be much appreciated.

@tazmad
Copy link
Author

tazmad commented May 27, 2019

I forgot to mention that within the ansible host file the server is defined as servername:port

@xpufx
Copy link

xpufx commented Mar 29, 2020

https://docs.rundeck.com/docs/administration/projects/node-execution/ssh.html

I'm trying to figure this out now.

It looks like rundeck's ansible node plugin is not importing the ssh port.

@hesne
Copy link

hesne commented Jan 12, 2021

any news about this topic. If I define the port as mention in docs it cannot resolve the hostname.

@Scifire
Copy link

Scifire commented Jan 19, 2021

running currently in the same issue...
Since in my case it´s only one node I could add it to a Rundeck Node File but ofc this is not the nice way.

@martin-gerdes
Copy link

martin-gerdes commented Aug 2, 2021

I am running into the same problem.
I am currently evaluating ansible+rundeck (to replace awx) for our company.
However, all our servers are running ssh on the (same) non-standard port.
So currently it looks to me as if the evaluation just failed...
Unless there is any news on this topic?

I see there is an open pull request in this direction: #281
That would at least be a functional workaround.

What would be really ideal though, would be just honoring the setting from ansible.cfg, which is read in after all:

[ssh_connection]
remote_port = an_integer

It seems pretty weird to me that rundeck itself doesn't have a setting for the standard ssh setting, just allowing overriding per host (which isn't discovered yet, so not an option), but that is of course outside of the scope of this plugin.

@martin-gerdes
Copy link

Workaround found, for our usecase of that ssh port being the same for all servers:
echo " Port an_integer" >> /etc/ssh/ssh_config

This doesn't help if any servers had a different ssh port, so this issue still deserves to stay open. But at least for our use case, this is good enough. :-)

@CorvetteCole
Copy link

CorvetteCole commented Mar 7, 2022

any update on this issue?

@joe-speedboat
Copy link

I can confirm, that this issue still exists, have one server in wan, which has non default ssh-port and:
ansible -m shell -a id myhost
works, but adhoc id comand fails in rundeck.
Would be great to have this issue get fixed one time

@huapox
Copy link

huapox commented Dec 1, 2023

+1

failed with:

[headless-arm64]
172.25.23.2 ansible_ssh_user=headless ansible_ssh_port=20022 hostname="172.25.23.2:20022" remote_port=20022
172.25.23.3 ansible_ssh_user=headless ansible_ssh_port=20022 hostname="172.25.23.3:20022" 

@djagoo
Copy link

djagoo commented Sep 10, 2024

Thats really bad, has anyone found a workaround for this when it's just one server using a different port for ssh and not all of them?

@huapox
Copy link

huapox commented Sep 10, 2024

works with: /etc/ansible/hosts_city

#; ;标准配置示例:  `主机昵称备注 ansible_ssh_host=主机IP:端口 ansible_ssh_user=用户`
#; ;sample:  `hostNick ansible_ssh_host=$IP:$PORT ansible_ssh_user=$USER`  (if $PORT=22, can be `ansible_ssh_host=$IP`)
[t1]
t1-1.1 ansible_ssh_host=192.168.1.1:2221 ansible_ssh_user=root
t1-1.2 ansible_ssh_host=192.168.1.2:2222 ansible_ssh_user=root
t1-1.3 ansible_ssh_host=192.168.1.3:2223 ansible_ssh_user=root

图片

@djagoo
Copy link

djagoo commented Sep 10, 2024

My hosts file is in yaml and has nearly every possible way included for this host to define a port. It seems like node discovery is working and using the right port but all commands etc. are using standard ssh port 22.

My current config:

testservers:
  hosts:
    test.test.example:9022:
      ansible_host: test.test.example
      ansible_port: 9022
      remote_port: 9022
      ansible_ssh_port: 9022

When I change this to:

testservers:
  hosts:
    test.test.example:     
      ansible_ssh_host: test.test.example:9022

the node disappears and I get a node source error "Failed Ansible Runner execution: ERROR: Ansible execution returned with non zero code."

When I try this:

[testservers]
test.test.example ansible_ssh_host=test.test.example:9022

I ended up with this error

test.test.example | UNREACHABLE! => {
    "changed": false,
    "msg": "Failed to connect to the host via ssh: ssh: Could not resolve hostname test.test.example:9022: Name or service not known",
    "unreachable": true
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants