# scp files with copy

**URL:** <https://forum.ansible.com/t/scp-files-with-copy/22238>\
**Category:** Ansible Project\
**Created:** [August 9, 2016, 12:36am UTC](https://forum.ansible.com/t/scp-files-with-copy/22238 "2016-08-09T00:36:42Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Eric\_Marquez](https://avatars.discourse-cdn.com/v4/letter/e/9d8465/32.png) [@Eric\_Marquez](https://forum.ansible.com/u/Eric_Marquez)\
**Post date:** [August 9, 2016, 12:36am UTC](https://forum.ansible.com/t/scp-files-with-copy/22238/1 "2016-08-09T00:36:42Z")

</div>

I'm attempting to copy a large file to a remote SCP server(Cisco Nexus Switch). I verified I can copy it using SCP but I have a large number of server to copy the files too. The server also happens to be a switch that accepts will receive packages via SCP. Reading the Ansible Docs it looks like the copy command should work but it's not from what I can tell.  
- copy: src:/my/local/path/file dest:/remote/path  
This should work but I'm seeing Ansible attempt to copy it to the local file system and not the remote filesystem. How do I force it to send the file to the remote server?

copy.yml

- name: copy firmware

&nbsp;&nbsp;hosts: all

&nbsp;&nbsp;remote\_user: admin

&nbsp;&nbsp;gather\_facts: no

&nbsp;&nbsp;connection: local

&nbsp;&nbsp;roles:

&nbsp;&nbsp;&nbsp;&nbsp;- copyfirmware

roles/copyfirmware/

└── tasks

&nbsp;&nbsp;&nbsp;&nbsp;└── main.yml

- copy: src=/srv/tftpboot/n3000-uk9.6.0.2.U6.6.bin dest=/n3000-uk9.6.0.2.U6.6.bin

Ansible/cisco/nexus$ ansible-playbook copyfirmware.yml --limit 3132hl-3-2a -vvvv  
Using ....Ansible/cisco/nexus/ansible.cfg as config file  
Loaded callback default of type stdout, v2.0

PLAYBOOK: copyfirmware.yml \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

1 plays in copyfirmware.yml

PLAY [copy firmware] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

TASK [copyfirmware : copy firmware to switch scp server] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

task path: /home/test/Solutions.Network.Automation/MAS/Ansible/cisco/nexus/roles/copyfirmware/tasks/main.yml:3

\<2001:4898:5808:ff94::3\> ESTABLISH LOCAL CONNECTION FOR USER: test

\<2001:4898:5808:ff94::3\> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo $HOME/.ansible/tmp/ansible-tmp-1470702388.81-164755256977347 `" && echo ansible-tmp-1470702388.81-164755256977347="` echo $HOME/.ansible/tmp/ansible-tmp-1470702388.81-164755256977347 `" ) && sleep 0'

\<2001:4898:5808:ff94::3\> PUT /tmp/tmpKR6wkE TO /home/test/.ansible/tmp/ansible-tmp-1470702388.81-164755256977347/stat

\<2001:4898:5808:ff94::3\> EXEC /bin/sh -c 'LANG=en\_US.UTF-8 LC\_ALL=en\_US.UTF-8 LC\_MESSAGES=en\_US.UTF-8 /usr/bin/python /home/test/.ansible/tmp/ansible-tmp-1470702388.81-164755256977347/stat; rm -rf "/home/test/.ansible/tmp/ansible-tmp-1470702388.81-164755256977347/" \> /dev/null 2\>&1 && sleep 0'

\<2001:4898:5808:ff94::3\> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo $HOME/.ansible/tmp/ansible-tmp-1470702388.93-56507575004650 `" && echo ansible-tmp-1470702388.93-56507575004650="` echo $HOME/.ansible/tmp/ansible-tmp-1470702388.93-56507575004650 `" ) && sleep 0'

\<2001:4898:5808:ff94::3\> PUT /srv/tftpboot/n3000-uk9-kickstart.6.0.2.U6.6.bin TO /home/test/.ansible/tmp/ansible-tmp-1470702388.93-56507575004650/source

\<2001:4898:5808:ff94::3\> PUT /tmp/tmpTFBEdq TO /home/test/.ansible/tmp/ansible-tmp-1470702388.93-56507575004650/copy

\<2001:4898:5808:ff94::3\> EXEC /bin/sh -c 'LANG=en\_US.UTF-8 LC\_ALL=en\_US.UTF-8 LC\_MESSAGES=en\_US.UTF-8 /usr/bin/python /home/test/.ansible/tmp/ansible-tmp-1470702388.93-56507575004650/copy; rm -rf "/home/test/.ansible/tmp/ansible-tmp-1470702388.93-56507575004650/" \> /dev/null 2\>&1 && sleep 0'

fatal: [3132hl-3-2a]: FAILED! =\> {"changed": false, "checksum": "c86f4bee0935fa724f8ab93d76c950fe7ef3a5cb", "failed": true, "invocation": {"module\_args": {"backup": false, "content": null, "delimiter": null, "dest": "/n3000-uk9-kickstart.6.0.2.U6.6.bin", "directory\_mode": null, "follow": false, "force": true, "group": null, "mode": null, "original\_basename": "n3000-uk9-kickstart.6.0.2.U6.6.bin", "owner": null, "regexp": null, "remote\_src": null, "selevel": null, "serole": null, "setype": null, "seuser": null, "src": "/home/test/.ansible/tmp/ansible-tmp-1470702388.93-56507575004650/source", "validate": null}}, "msg": "Destination / not writable"}

NO MORE HOSTS LEFT \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

[WARNING]: Could not create retry file 'copyfirmware.retry'. [Errno 2] No such file or directory: ''

PLAY RECAP \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

3132hl-3-2a : ok=0 changed=0 unreachable=0 failed=1

SCP from Ansible server using the CLI:

scp /srv/tftpboot/n3000-uk9-kickstart.6.0.2.U6.6.bin admin@x.x.x.59:/n3000-uk9-kickstart.6.0.2.U6.6.bin

The authenticity of host 'x.x.x.59 (x.x.x.59)' can't be established.

RSA key fingerprint is SHA256:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.

Are you sure you want to continue connecting (yes/no)? yes

Warning: Permanently added 'x.x.x.59' (RSA) to the list of known hosts.

3000-uk9-kickstart.6.0.2.U6.6.bin 100% 36MB 269.9KB/s 02:17

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [August 9, 2016, 7:58am UTC](https://forum.ansible.com/t/scp-files-with-copy/22238/2 "2016-08-09T07:58:46Z")

</div>

The reason the copy is to the local file system is this.  
Here you say all host should use connection local.
