[Solved] copy files to remote servers but in a directory which belongs to some other user?


Since you hint on having sudo configured for your connecting user david, the simplest thing you can do is use elevated permissions to copy the file and set its an ownership to goldy through owner parameter of the unarchive module:

- name: copy and untar latest tasks.tar.gz file
  unarchive:
    src: tasks.tar.gz
    dest: /data/files/tasks/
    owner: goldy
  become: true

For the question of how to configure sudoers to allow for executing commands on behalf of a user other than root, you need to learn how sudo and sudoers actually work (see the manual).

solved copy files to remote servers but in a directory which belongs to some other user?