TimeOut

Here’s my problem:

I have to make a playbook to execute on a large range of servers but those servers can go down anytime, i can lose connection at any moment so i need ansible to be able to failed the job when the server gets unreachable.

Now when i execute a script on the remote server using the raw/shell module to execute a swupdate script if the connection is lost while the script is running i dont get any error and ansible just freeze there no failure or anything it just freeze while doing the tasks and nothing goes on. I tried modify the timeout values but nothing seems to work.

Hello Marc-antoine Desrochers,

To avoid such kind of problems you can add -o ServerAliveInterval=NumberOfSeconds in “[ssh_connection]” from ansible.cfg.
Add the following in your ansible.cfg:

`
[ssh_connection]

ssh_args = -o ServerAliveInterval=n
`

Here, n is the ServerAliveInterval (seconds) which we use while connecting to the server through SSH. Set it between 1-255. This will cause ssh client to send null packets to server every n seconds to avoid connection timeout.

Thanks Soniya