1) If you want to reboot on any change just notify a handler
- yum:
...
notify: reboot
Note: "update_cache" makes "yum" report "changed" even when no package have
been changed (installed/upgraded/downgraded); hence "update_cache" in a
separate task.
2) If you want to reboot on a particular combination of changes register
"yum_result" and make your choice.
- yum:
...
register: yum_result
- command: shutdown -r
when: <condition based on yum_result>
Note: See details in
How to access information in ansible yum list result?
https://stackoverflow.com/questions/49272469/how-to-access-information-in-ansible-yum-list-result
Cheers,
-vlado