Something like this ? (directly copied from a play I use... not tweaked to your settings ;) )
#!/usr/bin/env ansible-playbook
# Fetch files from remote hosts
---
- hosts: all
gather_facts: yes
vars:
outputdir: "data"
infofiles:
- /etc/krb5.conf
- /etc/resolv.conf
- /etc/sysconfig/network-scripts/ifcfg-*
- /etc/sysconfig/network-scripts/route-*
- /etc/sudoers.d/*
become: yes
tasks:
- name: Fetch filenames
shell: "find {{infofiles|join(' ')}} -type f"
register: filenames
ignore_errors: yes
tags:
- filenames
- fetch
- name: Fetch config-files
fetch: src="{{item}}" dest="{{outputdir}}/"
with_items:
- /etc/passwd
- /etc/redhat-release
- "{{filenames.stdout_lines}}"
tags:
- fetch