Hi ansible users,
I have a playbook to reboot all my servers serially, using the “serial: 1” option in the playbook. I have the tasks:
However, some of my managed servers are not directly reachable from my laptop, so I usually connect to them via a bastion host. This means that the port 22 test will fail for them.
I thought about using the ping module instead, which should just do an SSH ping to a host. However, the ping module times out after a while when the underlying ssh connection times out, so I can’t make it wait long enough for the server to finish rebooting.
Does anyone have any ideas or suggestions on how to work around this?
Anand
“However, some of my managed servers are not directly reachable from my laptop, so I usually connect to them via a bastion host. This means that the port 22 test will fail for them.”
You could consider running Ansible from the bastion host, versus using an SSH jumphost which I infer you are using above.
The ping module doesn’t ICMP ping, BTW, it’s a basic Ansible connectivity test.
You could consider running Ansible from the bastion host, versus using an SSH jumphost which I infer you are using above.
Yes, by bastion, I meant an SSH jump host.
The ping module doesn’t ICMP ping, BTW, it’s a basic Ansible connectivity test.
Yes, I realise that the ansible ping module is not ICMP, but an SSH connection. The SSH jump host doesn’t have ansible installed, and I don’t have root access on it. I can of course install ansible in a virtualenv, but I was hoping for some cleverer way of detecting host down/up from within a playbook run from my laptop. I suppose my use-case is an outlier, so I’ll try to see what I can do on the jump host.
Yeah, I’m open to the idea of a ping module action_plugin that takes a ‘mode=icmp’ (default ssh).
You could also just do a “shell: ping” (making sure to ping just once) and register the return code.
i.e. local_action: ping …
I am running into a similar situation and have been thinking about using the shell: ping approach too. But what I came up in the following didn’t seem to do the trick. Would appreciate a hint:
Quick correction and follow-up:
I should have been more careful when cut-n-paste.
The task include file should be