The Ansible copy module can be used in ad hoc mode to quickly run a copy job:
ansible servers -m copy --args="src=./file1.txt dest=~/file1.txt"
The output of this command should look as follows:
Alternatively, this can be used in a playbook with various options for a personalized result:
---
- name: copy a file to hosts
hosts: servers
become: true
fast_gathering: false
tasks:
- name: copy a file to the home directory of a user
copy:
src: ./file1.txt
dest: ~/file1.txt
owner: setup
mode: 0766