Run Ansible modules inside a virtualenv

I've had to look way too long for a way to do this, so here it is.

I wanted to use the docker_container Ansible module on a Debian Jessie host, but it requires version docker-py >= 1.7.0 whereas Debian only has 0.5.3 in apt.
Installing with pip would be an option, but mixing OS libraries with newer ones through pip is pretty dirty... So here is how to do it cleanly in a separate virtualenv:

---
- name: Install virtualenv
  apt: name=virtualenv update_cache=yes cache_valid_time=3600

- name: Install docker-py inside of virtualenv
  pip: name=docker-py version=1.9.0 virtualenv=/opt/ansible_env

- name: Rancher container
  docker_container:
    name: rancher
    image: rancher/server
    memory: 1GB
    volumes:
    - /var/lib/rancher-mysql:/var/lib/mysql
    restart_policy: unless-stopped
  vars:
    ansible_python_interpreter: /opt/ansible_env/bin/python

The pip module will autocreate the virtualenv if its not yet there, and by overriding the ansible_python_interpreter variable on the container task, the module will be executed inside.