Using existing modules to determine whether to run a script?

I’ve started looking into Ansible and I quite like it.

Is it possible to run a shell script only if the yum module determines that a given package is -not- installed?

Or in more general terms, is there a convenient way to leverage existing modules to decide whether or not to run a task?

tasks/modules can register output register: var, you can use that in when: clause in all/any subsequent tasks.