How to find out if my Ubuntu/Debian Linux server needs a reboot

Originally published at:

I use ansible-playbook to update my VMs and bare metal servers hosted in a remote data center. How do I tell, whether the Ubuntu or Debian Linux server requires a reboot using the command line over ssh based session?