In the lab's certificate block, the rescue prints "one or more configuration changes failed, but the web service is still active". Is that true at the end of the play?
Not necessarily. A successful rescue lets the play continue, and the restart that a2ensite already queued still runs at the end; Apache then restarts with a site that points to a certificate that was never copied, and the restart fails.
* Rescue handles the failure, but not the restart that is still queued. *
Follow one run where copying the key fails (say files/itia.key was never generated):
- Earlier tasks enabled
mod_ssland the HTTPS site and notifiedRestart web service. - In the block, the key copy fails;
rescueprints its message. The failure is now handled, so the host stays in the play. - The remaining tasks run, and at the end the queued handler restarts Apache.
- Apache reads the enabled site, can't open
/etc/ssl/private/itia.key, and refuses to start. The handler task fails, and the web service is down, despite the message.
The message is true only while the play runs. A rescue should undo what depends on the failed step (for example a2dissite itia-lhe-ssl.conf) or fail the host on purpose (ansible.builtin.fail) after logging. Alternatively, copy the certificates before enabling the site that needs them.
Go deeper:
Handling errors with blocks (official docs) โ what a successful rescue means for the host and for handlers.