when item not in key of hash

Trying to figure out if the following is possible.

I have a hash map e.g.

tools:
a:
foobar: 1
b:
barfoo: 3

  • file: path=/some/dir/{{ item }} state=absent
    with_items: contents.stdout_lines
    when: item not in [[ list of tools keys ]]

I want [[ list of tools keys ]] to turn into [a,b] basically so the when clause could work. Any way to do this?

tools.keys() would give you all of the keys. However in Python/jinja2 this can be shortcut by just specifying tools such as:

when: item not in tools

Wow simple, thanks!