How to recover from expected connection loss?

Hi all,

I'm trying to reduce the size of the locale archive on CentOS 7.4 as described in [1] and [2]. Ansible version is 2.4.2.0-2.el7

For this I have a script on the client, that calls the needed commands:

###### /root/bin/rebuild_locale.sh
#!/bin/bash

LOCALES="en_US:de_DE"

mv /usr/lib/locale/locale-archive /usr/lib/locale/locale-archive.tmpl
build-locale-archive -l ${LOCALES}

You can use async on the task to fire and forget it.
And in the next task have wait_for to check when ssh is responding again.