# Copy: "source not found" from an action plugin

**URL:** <https://forum.ansible.com/t/copy-source-not-found-from-an-action-plugin/36182>\
**Category:** Ansible Project\
**Created:** [January 6, 2022, 3:18pm UTC](https://forum.ansible.com/t/copy-source-not-found-from-an-action-plugin/36182 "2022-01-06T15:18:58Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![yves\_baumes](https://avatars.discourse-cdn.com/v4/letter/y/c2a13f/32.png) [@yves\_baumes](https://forum.ansible.com/u/yves_baumes)\
**Post date:** [January 6, 2022, 3:18pm UTC](https://forum.ansible.com/t/copy-source-not-found-from-an-action-plugin/36182/1 "2022-01-06T15:18:58Z")

</div>

Hello,  
I am trying to create my own action plugin. Here it is :

myAction.py:

```auto
from ansible.plugins.action import ActionBase

class ActionModule(ActionBase):

def run(self, tmp=None, task_vars=None):
super(ActionModule, self).run(tmp, task_vars)

# print(f"tmp = {tmp}, task_vars = {task_vars}")

module_args = self._task.args.copy()
print(f"module_args = {module_args}")

module_return = self._execute_module(module_name='copy',
module_args=module_args,
task_vars=task_vars, tmp=tmp)

print(f"module_return = {module_return}")
ret = dict()
return dict(ansible_facts=dict(ret))

```

As you may see, it only tries to execute the copy module.

Here is the invocation:  
myaction.yml:

```auto
- name: test copy file
copy:
src: foo.txt
dest: /etc/foo2.txt

- name: test
myAction:
src: foo.txt
dest: /etc/foo.txt
remote_src: no

```

As you can see I am invoking first the normal copy module. Which works fine since I find the /etc/foo2.txt file on the remote machine. In second step I invoke myAction (the action plugin) which does not work as it returns a failure, and the /etc/foo.txt file is not created on the remote machine. Here is the result on the standard output:

```auto
TASK [myaction : test] ************************************************************************************************************************************************************************************
module_args = {'src': 'foo.txt', 'dest': '/etc/foo.txt', 'remote_src': False}
module_return = {'failed': True, 'msg': 'Source foo.txt not found', 'invocation': {'module_args': {'src': 'foo.txt', 'dest': '/etc/foo.txt', 'remote_src': False, 'backup': False, 'force': True, 'follow': False, 'unsafe_writes': False, '_original_basename': None, 'content': None, 'validate': None, 'directory_mode': None, 'local_follow': None, 'checksum': None, 'mode': None, 'owner': None, 'group': None, 'seuser': None, 'serole': None, 'selevel': None, 'setype': None, 'attributes': None}}, '_ansible_parsed': True}

```

As you can see the message is ‘Source foo.txt not found’. I’ve tried to specify an absolute path, it does not work either. I specify ‘remote\_src: no’ as well in the invokation of myAction.

Is someone able to tell me why the copy module is not able to find my foo.txt file in the second case (when invoked from my action plugin)?

Regards  
Yves

---

<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:** [January 10, 2022, 5:36pm UTC](https://forum.ansible.com/t/copy-source-not-found-from-an-action-plugin/36182/2 "2022-01-10T17:36:04Z")

</div>

because the copy module ONLY operates on the remote, the copy action  
plugin is the one that can see the src locally and copies it to a temp  
location on the remote for the copy module to find. remote\_src= exists  
in the module for 'compatibility' but really ONLY affects the action  
plugin.
