I have the following local set of files:
$ find . -maxdepth 2
.
./.DS_Store
./radio
./radio/server.properties
./radio/recordings/
./radio/requirements.txt
./radio/__pycache__
./radio/radio.iml
./radio/radio.py
./radio/audio.py
./ansibleplaybook.yml
./inventory
I would like to copy only the .py files such that my remote server looks like this:
$ find ~/radio/
/home/pi/radio/
/home/pi/radio/radio.py
/home/pi/radio/audio.py
I have used examples found here and in the Ansible documentation to come up with this playbook:
---
- hosts: all
tasks:
- name: Copy radio source
copy:
src: "radio"
dest: "~/radio"
with_fileglob:
- "*.py"
However, run I run this no directory is created and nothing is copied.
$ ansible-playbook -i inventory ansibleplaybook.yml -u pi
PLAY [pi] **************************************************************************************************************************************************
TASK [Gathering Facts] ************************************************************************************************************************************************
ok: [pi]
TASK [Copy radio source] **********************************************************************************************************************************************
PLAY RECAP ************************************************************************************************************************************************************
pi : ok=1 changed=0 unreachable=0 failed=0 skipped=1 rescued=0 ignored=0
If I specify the .py files individually then the radio directory is created and the .py file is copied. I know I only have two .py files now, but having to update my playbook every time I add a new python module will obviously start to get very tedious. How can I get the above playbook to work so that all the files that match the pattern are copied?