ad-hoc versus playbook: the copy module
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:
![](https://static.packt-cdn.com/products/9781789532937/graphics/f2bee6f3-ecaa-432b-88ca-7fbe9f383154.png)
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