# Copying asset files to a remote machine when running a module

**URL:** <https://forum.ansible.com/t/copying-asset-files-to-a-remote-machine-when-running-a-module/44906>\
**Category:** Get Help\
**Created:** [November 28, 2025, 1:25pm UTC](https://forum.ansible.com/t/copying-asset-files-to-a-remote-machine-when-running-a-module/44906 "2025-11-28T13:25:19Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![martijn](https://avatars.discourse-cdn.com/v4/letter/m/dbc845/32.png) [@martijn](https://forum.ansible.com/u/martijn)\
**Post date:** [November 28, 2025, 1:25pm UTC](https://forum.ansible.com/t/copying-asset-files-to-a-remote-machine-when-running-a-module/44906/1 "2025-11-28T13:25:19Z")

</div>

I am developing a module that generates a port.conf file for mellanox/nvidia switches running cumulus linux.

My module compares specified configuration with a template file that is specific to a model and contains all possible modes for each interface of that device. For example, sometimes enabling a port with a certain network speed necessarily disables another port, usually the adjacent port.

```auto
---
# Example of how i want to use my module.
# default port configuration is 1x100Gbit
# port1 is broken out to 4x10Gbit
# port2 is broken out to 2x50Gbit
- name: Test generate_ports_conf
  surf.cumulus.generate_ports_conf:
    default:
      breakout: 1
      speed: 100
    ports:
      - port: 1
        breakout: 4
        speed: 10
      - port: 2
        breakout: 2
        speed: 50

```

```auto
# Example snippet of a template file that i compare against
# port1 in the mode speed=10 and breakout=4 disables port2
---
name: msn4600
ports:
  port1:
    type: qsfp56
    modes:
      - speed: 1
        breakout: 4
        disables:
          - port2
      - speed: 10
        breakout: 4
        disables:
          - port2
      ...

```

While testing on remote machines i noticed that those yaml files containing the templates are not copied to the remote host, so naturally the module fails. I have not found any modules in the wild that copy assets to the remote machines.

How can i make ansible copy these files to the remote machines? They should accompany the rest of the module so that they are automatically cleaned up after the task is done.

---

<div class="post-metadata">

**Author:** ![bcoca](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/bcoca/32/9269_2.png) [@bcoca](https://forum.ansible.com/u/bcoca)\
**Post date:** [November 28, 2025, 3:58pm UTC](https://forum.ansible.com/t/copying-asset-files-to-a-remote-machine-when-running-a-module/44906/2 "2025-11-28T15:58:46Z")

</div>

you need an action plugin, `script` is one example that copies a file to the target, runs it and deletes it. Also see the `template` for another example, it uses the `copy` action once it generates the template on the controller to get it to the target

---

<div class="post-metadata">

**Author:** ![martijn](https://avatars.discourse-cdn.com/v4/letter/m/dbc845/32.png) [@martijn](https://forum.ansible.com/u/martijn)\
**Post date:** [November 29, 2025, 1:50pm UTC](https://forum.ansible.com/t/copying-asset-files-to-a-remote-machine-when-running-a-module/44906/3 "2025-11-29T13:50:14Z")

</div>

Thanks, that looks viable indeed. I will report back next week with the results once i’ve implemented this. I had no clue that this is what action plugins are for.

---

<div class="post-metadata">

**Author:** ![martijn](https://avatars.discourse-cdn.com/v4/letter/m/dbc845/32.png) [@martijn](https://forum.ansible.com/u/martijn)\
**Post date:** [December 1, 2025, 3:38pm UTC](https://forum.ansible.com/t/copying-asset-files-to-a-remote-machine-when-running-a-module/44906/4 "2025-12-01T15:38:26Z")

</div>

Is exactly what i was looking for, thanks.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [December 31, 2025, 3:39pm UTC](https://forum.ansible.com/t/copying-asset-files-to-a-remote-machine-when-running-a-module/44906/5 "2025-12-31T15:39:15Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
