Several things going on.
#0: Your post/email is dated May 9, but I didn't see this until
Tuesday May 14. This is not related to what you were asking about,
but the irony of a "timeout" question taking ~5 days to land is too
delicious not to mention.
#1: I have no idea what your
ssh_timeout_wait_for
variable might be set to. Maybe it isn't set, so the
default(5) may be kicking in. I don't
think it matters in any case, though, because of #2.
#2: Of all the possible modules you could invoke for your "Check
host reachability" task,
wait_for_connection
is perhaps the most opposite of what you're trying to accomplish.
The whole point of that module assumes the host in question is
actually down - probably because you just rebooted it in a prior
task - and you want to wait for it to come back up before
proceeding. And that's what it's doing: waiting until the host comes
back up or until the end of time (which, fortunately, comes sooner
in the lifespan of this task than it does for us out here in the
real world). Change this to
ansible.builtin.ping
(or almost anything else) to get the behavior you seek.
#3: "
timeout" is one of the most
horribly encapsulated concepts in Ansible (and a lot of other
software). It's used to describe aspects of
- connections,
- running times for
- tasks
- plays
- playbooks
- workflows
- pauses
- async task management
- before iterations
- between iterations
- plus whatever crazy foo any particular plugin might want to do
with a bit of spare time
- …
I say "encapsulated concepts" because, while all those things are
mentioned somewhere in the docs, there's no single place you can
look and see them all laid out side by side, compared and contrasted
where the interplay between them all is discussed. To be fair, none
of those specific docs where some timeout is discussed should be the
canonical home of such an overview. That "General Discussion of All
Things Timing" page is yet to be written.
To get a feel for
ping vs
wait_for_connection, consider this snippet
of bash script. You'll need to substitute actual host names for "
reachable.host" and "
unreachable.host". The tl;dr (too long,
didn't run) upshot is: you don't want to use
wait_for_connection
as a reachability test.
for module in ansible.builtin.ping ansible.builtin.wait_for_connection ; do
for ct in 2 20 ; do
printf "module: %s with connection_timeout: %d\n" $module $ct
time ansible all -i reachable.host,unreachable.host, -m $module -e connection_timeout=$ct -v
done
done