You're so close. You're passing in a list as a single item. Instead of
loop: - "{{ found_files.files | map(attribute='path') | map('basename') | list }}" do this: loop: "{{ found_files.files | map(attribute='path') | map('basename') | list }}" On 9/19/22 10:06 AM, dulhaver via Ansible Project wrote:
I manage to get something like this from a set_fact following the find TASK TASK [creating a list with the filenames] ************************************************************* task path: /home/gwagner/repos/ansible/open_source/postgres_create_service/tasks/fetchsomething.yml:20 ok: [vm-414001-0227.step.zrz.dvz.cn-mv.de] => { "ansible_facts": { "env_files": [ "/opt/db/postgres/bin/.pg-service10.env", "/opt/db/postgres/bin/.pg-service11.env", "/opt/db/postgres/bin/.pg-service12.env", "/opt/db/postgres/bin/.pg-service13.env", "/opt/db/postgres/bin/.pg-service14.env", "/opt/db/postgres/bin/.pg-service15.env", "/opt/db/postgres/bin/.pg-service16.env", "/opt/db/postgres/bin/.pg-service17.env", "/opt/db/postgres/bin/.pg-service18.env" ] }, "changed": false } ******************************************************************************************************* so, it looks I would be getting closer, but obviousely need to fond a way to feed this as single items into a koop pf a fetch TASK. At the moment this is bein interpreted as one long string "item": [ ".pg-service10.env", ".pg-service11.env", ".pg-service12.env", ".pg-service13.env", ".pg-service14.env", ".pg-service15.env", ".pg-service16.env", ".pg-service17.env", ".pg-service18.env" ], "msg": "the remote file does not exist, not transferring, ignored" which to no big surprise isn't recognized as what it should by the fetch TASK here is the entire part of the playbook addressing the fetching ################################################################################### --- # TASKS for fetching all .env files from a Postgres DBaaS Machine - name: finding all .pg-*.env files from the server ansible.builtin.find: paths: "/opt/db/postgres/bin" hidden: true recurse: true file_type: any patterns: '*pg-service1*.env' register: found_files become: true - name: creating a list with the filenames set_fact: env_files: "{{ found_files.files | map(attribute='path') }}" - name: fetch all .env files into a "fetched" folder on Ansible machine ansible.builtin.fetch: src: "/opt/db/postgres/bin/{{ item }}" dest: fetched/ flat: true become: yes loop: - "{{ found_files.files | map(attribute='path') | map('basename') | list }}" ###################################################################################
-- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop receiving emails from it, send an email to ansible-project+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/06300153-31e8-9172-13c3-27cd916ae8f1%40gmail.com.