# Ansible copy files from remote host to network share

**URL:** <https://forum.ansible.com/t/ansible-copy-files-from-remote-host-to-network-share/30362>\
**Category:** Ansible Project\
**Created:** [May 17, 2019, 10:10pm UTC](https://forum.ansible.com/t/ansible-copy-files-from-remote-host-to-network-share/30362 "2019-05-17T22:10:45Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![asmagana](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/asmagana/32/2963_2.png) [@asmagana](https://forum.ansible.com/u/asmagana)\
**Post date:** [May 17, 2019, 10:10pm UTC](https://forum.ansible.com/t/ansible-copy-files-from-remote-host-to-network-share/30362/1 "2019-05-17T22:10:45Z")

</div>

I am trying to get a playbook to run the open-scap scanner but I need those results on the remote host to be copied over to a network share I am trying something like this but getting “permission denied”

`

- name: find it  
find:  
path: /tmp/  
patterns: ‘_\_oscap\_results.html,_\_oscap\_arf.xml’  
register: oscap\_results

- name: copy it  
fetch:  
src: “{{ item.path }}”  
dest: /mnt/SCAP/

`

Thanks for any tips.

Andy Magana  
Oklahoma City.

---

<div class="post-metadata">

**Author:** ![Knut\_Karevoll](https://avatars.discourse-cdn.com/v4/letter/k/5e9695/32.png) [@Knut\_Karevoll](https://forum.ansible.com/u/Knut_Karevoll)\
**Post date:** [May 18, 2019, 6:34pm UTC](https://forum.ansible.com/t/ansible-copy-files-from-remote-host-to-network-share/30362/2 "2019-05-18T18:34:49Z")

</div>

I am assuming you cut out a line too early and that you are looping over the oscap\_resultfor the last line there. You also do not mention where and how the network share is mounted. The fetch module copies the file from the remote to the local node. So it is equivilant to running "scp {{ansible\_user}}@{{ansible\_ssh\_address}}:/tmp/`*_oscap_results.html /mnt/SCAP/{{ansible_hostname}}/tmp/". So make sure that /mnt/SCAP/ is mounted on the node you are running ansible from and that you have the permission to create files and directories there. You might also look at the "copy" module with "remote_src: True" if the network share is mounted on the remote node.`
