# yum enablerepo won't do multiple repositories

**URL:** <https://forum.ansible.com/t/yum-enablerepo-wont-do-multiple-repositories/15062>\
**Category:** Ansible Project\
**Created:** [April 21, 2014, 11:58pm UTC](https://forum.ansible.com/t/yum-enablerepo-wont-do-multiple-repositories/15062 "2014-04-21T23:58:04Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![mtovey](https://avatars.discourse-cdn.com/v4/letter/m/f0a364/32.png) [@mtovey](https://forum.ansible.com/u/mtovey)\
**Post date:** [April 21, 2014, 11:58pm UTC](https://forum.ansible.com/t/yum-enablerepo-wont-do-multiple-repositories/15062/1 "2014-04-21T23:58:04Z")

</div>

Is anyone else having issues with the yum module’s enablerepo parameter? Suddenly I can’t enter multiple repositories. I am doing the following:

ansible server -s -K -m yum -a “name=package enablerepo=repo1,repo2 state=latest”

It consistently returns:

“msg”: “Error setting/accessing repo repo2: Error getting repository data for repo2, repository not found”

It is always the second repository that cannot be found (i.e. if I swap the order, then it will be repo1 that cannot be found). If I enable only one repository, then there is no issue. I am sure I have used this before, but now it does not work. I recently upgraded to 1.5.3 from 1.4.3, but I experienced the issue with both versions. I know that I was able to do this previously, perhaps in a version prior to 1.4.3  
Thanks,  
-Mark

---

<div class="post-metadata">

**Author:** ![Strahinja\_Kustudic2](https://avatars.discourse-cdn.com/v4/letter/s/b4bc9f/32.png) [@Strahinja\_Kustudic2](https://forum.ansible.com/u/Strahinja_Kustudic2)\
**Post date:** [April 22, 2014, 10:06pm UTC](https://forum.ansible.com/t/yum-enablerepo-wont-do-multiple-repositories/15062/2 "2014-04-22T22:06:17Z")

</div>

I just tried this with the development version (1.6) and with 1.4.4 and all worked.

$ ansible server-01 -m yum -a ‘name=package enablerepo=repo1,repo2 state=latest’

---

<div class="post-metadata">

**Author:** ![mtovey](https://avatars.discourse-cdn.com/v4/letter/m/f0a364/32.png) [@mtovey](https://forum.ansible.com/u/mtovey)\
**Post date:** [April 22, 2014, 11:03pm UTC](https://forum.ansible.com/t/yum-enablerepo-wont-do-multiple-repositories/15062/3 "2014-04-22T23:03:14Z")

</div>

So perhaps it has something to do with how I have my repositories configured. They look similar to the following:

repo1:  
[repo1]  
name=Repository 1  
baseurl=[http://repositoryserver/Repo1/$releasever/$basearch](http://repositoryserver/Repo1/$releasever/$basearch)  
gpgcheck=0  
enabled=0

repo2:  
[repo2]  
name=Repository 2  
baseurl=[http://repositoryserver/Repo1/$releasever/$basearch](http://repositoryserver/Repo1/$releasever/$basearch)  
gpgcheck=0  
enabled=0

The two repositories are intentionally kept disabled by default and are enabled as needed with the “enablerepo=” argument to yum. This works fine when I run yum manually, but fails when I try to run it with Ansible. If it is working for you, then I must be missing something. Any ideas?  
Thanks,  
-Mark

---

<div class="post-metadata">

**Author:** ![Strahinja\_Kustudic2](https://avatars.discourse-cdn.com/v4/letter/s/b4bc9f/32.png) [@Strahinja\_Kustudic2](https://forum.ansible.com/u/Strahinja_Kustudic2)\
**Post date:** [April 22, 2014, 11:30pm UTC](https://forum.ansible.com/t/yum-enablerepo-wont-do-multiple-repositories/15062/4 "2014-04-22T23:30:57Z")

</div>

I tried disabling both of my repos and started it again and it still worked. Could you try running ansible with **-vvvv**?

---

<div class="post-metadata">

**Author:** ![mtovey](https://avatars.discourse-cdn.com/v4/letter/m/f0a364/32.png) [@mtovey](https://forum.ansible.com/u/mtovey)\
**Post date:** [April 23, 2014, 12:07am UTC](https://forum.ansible.com/t/yum-enablerepo-wont-do-multiple-repositories/15062/5 "2014-04-23T00:07:47Z")

</div>

I even went into the Python code and commented out the cleanup routines so that the tmp files would persist after execution (is there an easier way to do that?). When I looked into the Python yum file that was copied to the target, I found this:

MODULE\_ARGS = ‘name=ansible enablerepo=uti\_EPEL,ol6\_latest state=latest’

So the arguments are being passed properly. But somewhere further on there is a disconnect in the interface to the actual yum command.

Below is what is output by ansible -vvv.  
Thanks,  
-Mark

ESTABLISH CONNECTION FOR USER: ansible on PORT 22 TO serv1  
 REMOTE\_MODULE yum name=ansible enablerepo=uti\_EPEL,ol6\_latest state=latest  
 EXEC /bin/sh -c ‘mkdir -p $HOME/.ansible/tmp/ansible-tmp-1398210973.51-184022099032293 && chmod a+rx $HOME/.ansible/tmp/ansible-tmp-1398210973.51-184022099032293 && echo $HOME/.ansible/tmp/ansible-tmp-1398210973.51-184022099032293’  
 PUT /tmp/tmpC7FuQx TO /home/ansible/.ansible/tmp/ansible-tmp-1398210973.51-184022099032293/yum  
 EXEC /bin/sh -c ‘sudo -k && sudo -H -S -p “[sudo via ansible, key=sbkgbcrmqwvqpushkumibwbbbcfwyqvd] password: " -u root /bin/sh -c '”’“‘echo SUDO-SUCCESS-sbkgbcrmqwvqpushkumibwbbbcfwyqvd; /usr/bin/python -tt /home/ansible/.ansible/tmp/ansible-tmp-1398210973.51-184022099032293/yum; rm -rf /home/ansible/.ansible/tmp/ansible-tmp-1398210973.51-184022099032293/ \>/dev/null 2\>&1’”‘"’’  
serv1 | FAILED \>\> {  
“failed”: true,  
“msg”: “Error setting/accessing repo ol6\_latest: Error getting repository data for ol6\_latest, repository not found”

---

<div class="post-metadata">

**Author:** ![Strahinja\_Kustudic2](https://avatars.discourse-cdn.com/v4/letter/s/b4bc9f/32.png) [@Strahinja\_Kustudic2](https://forum.ansible.com/u/Strahinja_Kustudic2)\
**Post date:** [April 23, 2014, 8:19am UTC](https://forum.ansible.com/t/yum-enablerepo-wont-do-multiple-repositories/15062/6 "2014-04-23T08:19:26Z")

</div>

If I can see correctly you are using sudo, I wasn’t using sudo, maybe there is a problem with that?

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [April 23, 2014, 1:34pm UTC](https://forum.ansible.com/t/yum-enablerepo-wont-do-multiple-repositories/15062/7 "2014-04-23T13:34:23Z")

</div>

Please make sure there is a github ticket if you would like us to investigate.

Thanks!

---

<div class="post-metadata">

**Author:** ![mtovey](https://avatars.discourse-cdn.com/v4/letter/m/f0a364/32.png) [@mtovey](https://forum.ansible.com/u/mtovey)\
**Post date:** [April 23, 2014, 3:55pm UTC](https://forum.ansible.com/t/yum-enablerepo-wont-do-multiple-repositories/15062/8 "2014-04-23T15:55:21Z")

</div>

At this point, I am still trying to decide if I have found a real bug, or if I am just doing something stupid outside of Ansible. The yum module is fairly important and nobody else seems to be complaining about this, so I am leaning more towards my own configuration. I want to try to eliminate that before I make everyone jump through hoops to solve a problem that is specific to me, although it is a bit difficult to see what is happening down inside the code. There are a few other places I can look first (log files on the repository itself). If that doesn’t shed some light, then I guess I will have to reach out more.  
Thanks,  
-Mark

---

<div class="post-metadata">

**Author:** ![mtovey](https://avatars.discourse-cdn.com/v4/letter/m/f0a364/32.png) [@mtovey](https://forum.ansible.com/u/mtovey)\
**Post date:** [April 23, 2014, 5:04pm UTC](https://forum.ansible.com/t/yum-enablerepo-wont-do-multiple-repositories/15062/9 "2014-04-23T17:04:56Z")

</div>

Okay, I am totally stymied. I could see no hits in the repository logs from my target server. I ran tcpdump to capture network on the target server to see if it might be reaching out to another repository in error, but the only traffic I saw was to the Ansible server, never to the repository. So from is appears that the yum module is simply not locating all of the repository information in the yum repository configuration files.  
I guess I will have to open a ticket. I have not used GitHub before, so this will be a learning experience too.  
-Mark

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [April 24, 2014, 2:36pm UTC](https://forum.ansible.com/t/yum-enablerepo-wont-do-multiple-repositories/15062/10 "2014-04-24T14:36:43Z")

</div>

As mentioned above, it’s probably a glitch in some code that hasn’t been heavily utilized in a while.

Not too many people use the enablerepo parameter, and probably less with multiple-repos passed to the parameter, and the yum API, particularly when used with yum RHN plugin, occasionally has small differences between OS versions.

---

<div class="post-metadata">

**Author:** ![mtovey](https://avatars.discourse-cdn.com/v4/letter/m/f0a364/32.png) [@mtovey](https://forum.ansible.com/u/mtovey)\
**Post date:** [April 24, 2014, 4:17pm UTC](https://forum.ansible.com/t/yum-enablerepo-wont-do-multiple-repositories/15062/11 "2014-04-24T16:17:19Z")

</div>

I saved the tmp file on a target server and looked through it to try to see what is happening. I was able to isolate the issue to this code snippet:

current\_repos = my.repos.repos.keys()  
for r in en\_repos:  
try:  
my.repos.enableRepo(r)`  
new\_repos = my.repos.repos.keys()  
for i in new\_repos:  
if not i in current\_repos:  
rid = my.repos.getRepo(i)  
a = rid.repoXML.repoid  
current\_repos = new\_repos  
except yum.Errors.YumBaseError, e:  
module.fail\_json(msg=“Error setting/accessing repo %s: %s” % (r, e))

I added some print statements to output repo information as the code is executed:

current\_repos = my.repos.repos.keys()  
**print (“current\_repos = %s” % (current\_repos))**  
for r in en\_repos:  
**print (“checking repo %s against %s” % (r, current\_repos))**  
try:  
my.repos.enableRepo(r)  
new\_repos = my.repos.repos.keys()  
**print (“new\_repos = %s” % (new\_repos))**  
for i in new\_repos:  
**print (“testing repo %s against %s” % (i, current\_repos))**  
if not i in current\_repos:  
rid = my.repos.getRepo(i)  
a = rid.repoXML.repoid  
current\_repos = new\_repos  
except yum.Errors.YumBaseError, e:  
module.fail\_json(msg=“Error setting/accessing repo %s: %s” % (r, e))

That generates this output:

current\_repos = [‘ol6\_latest’, ‘uti\_EPEL’, ‘ol6\_u4\_base’]  
checking repo: uti\_EPEL against [‘ol6\_latest’, ‘uti\_EPEL’, ‘ol6\_u4\_base’]  
new\_repos = [‘uti\_EPEL’]  
testing repo uti\_EPEL against [‘ol6\_latest’, ‘uti\_EPEL’, ‘ol6\_u4\_base’]  
**checking repo: ol6\_latest against [‘uti\_EPEL’]**  
{“msg”: “Error setting/accessing repo ol6\_latest: Error getting repository data for ol6\_latest, repository not found”, “failed”: true}

So, at the highlighted line, the list of repositories that the current repository is being tested against has been reduced to just the previously tested repository.  
Now, I am not a Python programmer (I bought a “Learning Python” book a couple of months ago, but haven’t had time to go through it yet) and it was a stretch for me to get this far. I am not sure where to go from here, but hopefully someone more knowledgeable can look into it and carry the torch from here.  
Thanks,  
-Mark

---

<div class="post-metadata">

**Author:** ![James\_Martin1](https://avatars.discourse-cdn.com/v4/letter/j/0ea827/32.png) [@James\_Martin1](https://forum.ansible.com/u/James_Martin1)\
**Post date:** [April 25, 2014, 4:32pm UTC](https://forum.ansible.com/t/yum-enablerepo-wont-do-multiple-repositories/15062/12 "2014-04-25T16:32:57Z")

</div>

Mark,

Thanks for digging into the issue. Would you mind updating the github ticket with this new information?

Thanks!

James

---

<div class="post-metadata">

**Author:** ![mtovey](https://avatars.discourse-cdn.com/v4/letter/m/f0a364/32.png) [@mtovey](https://forum.ansible.com/u/mtovey)\
**Post date:** [April 25, 2014, 10:25pm UTC](https://forum.ansible.com/t/yum-enablerepo-wont-do-multiple-repositories/15062/13 "2014-04-25T22:25:41Z")

</div>

Done! Except I see that the test formatting ( **bold** ) didn’t carry across. But I think there is still enough information there that someone can figure out what i meant.  
Thanks,  
Mark
