# Question about source files in an Ansible Collection

**URL:** <https://forum.ansible.com/t/question-about-source-files-in-an-ansible-collection/38071>\
**Category:** Ansible Project\
**Tags:** rhel\
**Created:** [June 7, 2023, 6:16pm UTC](https://forum.ansible.com/t/question-about-source-files-in-an-ansible-collection/38071 "2023-06-07T18:16:35Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![harry\_devine](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/harry_devine/32/5293_2.png) [@harry\_devine](https://forum.ansible.com/u/harry_devine)\
**Post date:** [June 7, 2023, 6:16pm UTC](https://forum.ansible.com/t/question-about-source-files-in-an-ansible-collection/38071/1 "2023-06-07T18:16:35Z")

</div>

I have a collection that I’ve built with numerous roles in it. Under one of the roles, I have a files folder with some files in it used during the role execution. However, I have a situation where 2 of these files keep erroring out saying that the source isn’t found.

For example, I have one file that I use the unarchive module to extract it, and it works:

- name: Branding | Extract the jar file  
ansible.builtin.unarchive:  
src: files/tsose.jar  
dest: /var/tmp/guacbranding

But when I try to install an RPM that is located in the same files folder, I get an error stating that the source file is not found:

- name: Install Latest RHEL 7 MySQL Connector  
ansible.builtin.yum:  
name: files/mysql-connector-j-8.0.33-1.el7.noarch.rpm  
state: present  
disable\_gpg\_check: true

I even tried to copy the file locally using the copy module with the remote\_src flag set to true, but I get the same “file not found” error. And when I check the tar file that is created and I upload to our automation hub, the files are there under files.

Any ideas?

Thanks,  
Harry

---

<div class="post-metadata">

**Author:** ![vbotka](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/vbotka/32/359_2.png) [@vbotka](https://forum.ansible.com/u/vbotka)\
**Post date:** [June 8, 2023, 12:10am UTC](https://forum.ansible.com/t/question-about-source-files-in-an-ansible-collection/38071/2 "2023-06-08T00:10:25Z")

</div>

Absolute path on the remote host is required

&nbsp;&nbsp;if spec.endswith('.rpm') or '://' in spec:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if '://' not in spec and not os.path.exists(spec):  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;res['msg'] += "No RPM file matching '%s' found on system" % spec

[https://github.com/ansible/ansible/blob/devel/lib/ansible/modules/yum.py#L1040](https://github.com/ansible/ansible/blob/devel/lib/ansible/modules/yum.py#L1040)

---

<div class="post-metadata">

**Author:** ![harry\_devine](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/harry_devine/32/5293_2.png) [@harry\_devine](https://forum.ansible.com/u/harry_devine)\
**Post date:** [June 8, 2023, 11:42am UTC](https://forum.ansible.com/t/question-about-source-files-in-an-ansible-collection/38071/3 "2023-06-08T11:42:48Z")

</div>

Fair enough. Then why wouldn’t the following work (trying to copy the RPM to the host, then running the yum module from that path)?:

- name: Config | Handle RHEL 7 MySQL Connector  
when: (guacamole\_mysql\_auth) and (ansible\_distribution\_major\_version == ‘7’)  
block:
- name: Copy the RPM locally  
ansible.builtin.copy:  
src: files/mysql-connector-j-8.0.33-1.el7.noarch.rpm  
dest: /var/tmp/  
owner: root  
group: root  
mode: 0644  
remote\_src: true
- name: Install Latest RHEL 7 MySQL Connector  
ansible.builtin.yum:  
name: /var/tmp/mysql-connector-j-8.0.33-1.el7.noarch.rpm  
state: present  
disable\_gpg\_check: true
- name: Remove local RPM file  
ansible.builtin.file:  
path: /var/tmp/mysql-connector-j-8.0.33-1.el7.noarch.rpm  
state: absent

Thanks,  
Harry

---

<div class="post-metadata">

**Author:** ![vbotka](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/vbotka/32/359_2.png) [@vbotka](https://forum.ansible.com/u/vbotka)\
**Post date:** [June 8, 2023, 12:52pm UTC](https://forum.ansible.com/t/question-about-source-files-in-an-ansible-collection/38071/4 "2023-06-08T12:52:50Z")

</div>

This copy is rather confusing. You said the directory \*files\* is in a  
role, i.e. on the controller. Now you set \*remote\_src: true\* which  
takes the source from the remote host.

To isolate the problem. You should verify each step you make. In this  
case, before you run \*yum\*, verify the file  
\*/var/tmp/mysql-connector-j-8.0.33-1.el7.noarch.rpm\* is present and  
readable.

---

<div class="post-metadata">

**Author:** ![harry\_devine](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/harry_devine/32/5293_2.png) [@harry\_devine](https://forum.ansible.com/u/harry_devine)\
**Post date:** [June 8, 2023, 5:29pm UTC](https://forum.ansible.com/t/question-about-source-files-in-an-ansible-collection/38071/5 "2023-06-08T17:29:51Z")

</div>

The remote\_src ended up being the issue with the copy. Once i removed that, I was able to copy the RPM file, then give the absolute path to the yum/dnf module, and install as expected. Thanks for the assistance!

Thanks,  
Harry
