copy result of a find command using register

Hello,

I have placed below tasks in a role. It works fine when executing the complete role, but when i run my playbook and I include a tag “-- tags copy_files”, my registered “result_files” is not included.
What would be the best approach for this where I only use run my playbook with the copy_files tag?

  • name: Register - Copy files
    command: “find ./demo_deploy -type f ! -path ‘./demo_deploy/ins/*’”
    register: result_files

  • name: Copy files
    command: cp {{ item }} /tmp/
    with_items:

  • “{{result_files.stdout_lines}}”
    tags:

  • copy_filesed