ansible "when:" directive: check file exists, and other nifty things?

I can run a task conditionally, depending on the existence of a file, as follows:

  • name: check if the file exists
    stat: path=/my/file
    register: file_register
  • name: do the actual task
    include: my_subtask.yml
    when: not file_register.stat.exists

Is it not possible to do smarter things in the when clause? Possible with a Jinja2 directive? I tried to search for the documentation of the lookup() function I see sometimes, but cannot find it. Is is part of Ansible or of Jinja? Is it usable here?

Thanks in advance,
Eric

lookups are part of ansible, lookups run only on the 'master' so for
this to work all actions would be local.