# Failed to copy repo to /etc/yum.repos.d

**URL:** <https://forum.ansible.com/t/failed-to-copy-repo-to-etc-yum-repos-d/30603>\
**Category:** Ansible Project\
**Created:** [June 19, 2019, 3:56pm UTC](https://forum.ansible.com/t/failed-to-copy-repo-to-etc-yum-repos-d/30603 "2019-06-19T15:56:40Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Annam\_Rafi1](https://avatars.discourse-cdn.com/v4/letter/a/e79b87/32.png) [@Annam\_Rafi1](https://forum.ansible.com/u/Annam_Rafi1)\
**Post date:** [June 19, 2019, 3:56pm UTC](https://forum.ansible.com/t/failed-to-copy-repo-to-etc-yum-repos-d/30603/1 "2019-06-19T15:56:40Z")

</div>

![Screen Shot 2019-06-19 at 11.51.35 AM.png](https://us1.discourse-cdn.com/ansible/original/2X/1/1bd35b0438d8432bc3e735e79b3ea4c0ee6e3da0.png)

I tried to use the yum\_repository module to create a custom repo but I am failing to do so. I was getting a permission denied so I evaluated the permissions.

---

<div class="post-metadata">

**Author:** ![Annam\_Rafi1](https://avatars.discourse-cdn.com/v4/letter/a/e79b87/32.png) [@Annam\_Rafi1](https://forum.ansible.com/u/Annam_Rafi1)\
**Post date:** [June 19, 2019, 3:57pm UTC](https://forum.ansible.com/t/failed-to-copy-repo-to-etc-yum-repos-d/30603/2 "2019-06-19T15:57:59Z")

</div>

this is my inventory txt file. what am i missing?

 ![Screen Shot 2019-06-19 at 11.57.09 AM.png](https://us1.discourse-cdn.com/ansible/original/2X/b/baf7f10fe63e093143118ffb399b16332fd81ed9.png)

---

<div class="post-metadata">

**Author:** ![Robert\_Williams](https://avatars.discourse-cdn.com/v4/letter/r/eb8c5e/32.png) [@Robert\_Williams](https://forum.ansible.com/u/Robert_Williams)\
**Post date:** [June 19, 2019, 4:13pm UTC](https://forum.ansible.com/t/failed-to-copy-repo-to-etc-yum-repos-d/30603/3 "2019-06-19T16:13:28Z")

</div>

Have you validated that the user in question has the rights to make the change and that your become is valid?

You could add a task before the repo change using `shell: whoami` to make sure the become is working properly.

Also not sure if you need the single quotes on the ansible\_become\_user and ansible\_become\_method vars in the inventory file.

I havent used the yum\_repository - I have previously just used a J2 template to place the repo files.

---

<div class="post-metadata">

**Author:** ![Annam\_Rafi](https://avatars.discourse-cdn.com/v4/letter/a/b2d939/32.png) [@Annam\_Rafi](https://forum.ansible.com/u/Annam_Rafi)\
**Post date:** [June 19, 2019, 4:25pm UTC](https://forum.ansible.com/t/failed-to-copy-repo-to-etc-yum-repos-d/30603/4 "2019-06-19T16:25:01Z")

</div>

Yes this user is in the sudoers file with full permissions. As an alternative, I created the repo file my home directory and then tried to copy it into /etc/yum.repos.d but im getting an error of “: FAILED! =\> {“changed”: false, “msg”: “Destination /etc/yum.repos.d not writable”}”

---

<div class="post-metadata">

**Author:** ![Dick\_Visser](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@Dick\_Visser](https://forum.ansible.com/u/Dick_Visser)\
**Post date:** [June 19, 2019, 8:57pm UTC](https://forum.ansible.com/t/failed-to-copy-repo-to-etc-yum-repos-d/30603/5 "2019-06-19T20:57:29Z")

</div>

> Yes this user is in the sudoers file with full permissions. As an alternative, I created the repo file my home directory and then tried to copy it into /etc/yum.repos.d but im getting an error of “: FAILED! =\> {“changed”: false, “msg”: “Destination /etc/yum.repos.d not writable”}”

This basically proves that your privilege elevating logic isn’t working.  
Fix that and your yum command will work as well.

---

<div class="post-metadata">

**Author:** ![Robert\_Williams](https://avatars.discourse-cdn.com/v4/letter/r/eb8c5e/32.png) [@Robert\_Williams](https://forum.ansible.com/u/Robert_Williams)\
**Post date:** [June 19, 2019, 9:03pm UTC](https://forum.ansible.com/t/failed-to-copy-repo-to-etc-yum-repos-d/30603/6 "2019-06-19T21:03:48Z")

</div>

Also looks like your ansible user and your ansible become user are the same. Is that desired? I would imagine those files are owned by root, so suspect you need to have root as your ansible become user to have rights.
