Tutorials focusing on Linux, programming, and open-source

Ansible - Update And Reboot (if required) Amazon Linux Servers

Below is the playbook I use for updating my Amazon Linux servers. This will reboot the servers if they receive an updated kernel. It has to run a custom ssh command because unlike Ubuntu, there is no reboot-required file to indicate a reboot is required. The script is one I customized, but is largely based on the content linked to in the references.

You will need to change hosts: amazon-linux-servers to whatever you have called your hosts in your ansible hosts file.

References

We are a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for us to earn fees by linking to Amazon.com and affiliated sites. More info.