title: Ansible testing variable type
body: <p>I'm using an existing role, and I wish to modify it to extend its capabilities. Currently, one of its tasks is to create directories. These directories get passed as a variable containing a list of strings to the role, and then iterated over in a <code>with_items</code> statement. However, I would prefer to pass a list of dictionaries of the form e.g. <code>{name: foo, mode: 751}</code>.</p>
  
  <p>So far so good; I can simply edit the role to make it take this sort of input. However, I also want to make it backwards compatible with the old format, i.e. where the items are strings.</p>
  
  <p>Is there a way to test the type of a variable and then return different values (or perform different tasks) based on this? Perhaps using a Jinja2 filter? I was briefly looking at the <a href="https://docs.ansible.com/ansible/playbooks_conditionals.html" rel="nofollow">conditionals</a> listed in the manual, but nothing caught my eye that could be used in this situation.</p>