Search code examples
linuxansiblescp

Ansible scp error - No such file or directory


I'm running a fairly simple Ansible script to copy a directory to all machines in a group.

- name: patch python patches
  hosts: group1
  user: root
  tasks:
     - name: scp the python files to all servers
       local_action: command scp -rp /data/patches_additional_files/16_1_20_002/* {{ ansible_ssh_host }}:/opt/lib/

When I execute the scp command manually the file transfers as planned:

command scp -rp /data/patches_additional_files/16_1_20_002/* localhost:/opt/lib/

when I execute the Ansible playbook it raises an error:

"/data/patches_additional_files/16_1_20_002/*": "No such file or directory"


Solution

  • It looks ansible doesn't like the asterisk (*) anymore. I looped over the directories from my python script and added each directory to the scp command.