Using Ansible to check version before install or upgrade

Before copying source code, configuring, compiling, and installing a software package via Ansible, first check to see if the target package is already installed and at the target version. This post includes Ansible tasks to perform those checks and covers a couple common pitfalls along the way.