---
- hosts: localhost
  gather_facts: False
  vars:
    filelist:
      - "one"
      - "/etc/motd"
      - "two"
    # Fake vars because this is just a test
    role_path: /etc/ansible
    ansible_distribution: fedora
    ansible_distribution_version: 27
    ansible_distribution_major_version: 27
  tasks:
  - debug:
      var: item
    loop: '{{ q("first_found", ["one", "/etc/motd", "three"]) }}'

  - debug:
      var: item
    loop: '{{ q("first_found", *filelist) }}'

  - debug:
      var: item
    loop: '{{ q("first_found",
                "{{ role_path }}/vars/{{ ansible_distribution }}-{{ ansible_distribution_version }}.yml",
                "{{ role_path }}/vars/{{ ansible_distribution }}-{{ ansible_distribution_major_version }}.yml",
                "{{ role_path }}/vars/{{ ansible_distribution }}.yml",
                "{{ role_path }}/vars/default.yml",
                "/etc/motd",
           ) }}'
