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
hosts: all
remote_user: admin
gather_facts: no
connection: local
roles:
- copyfirmware
roles/copyfirmware/
└── tasks
└── 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