[PUP-2916] yumrepo fails to honour custom reposdir Created: 2014/07/09  Updated: 2019/04/04  Resolved: 2015/03/02

Status: Closed
Project: Puppet
Component/s: Types and Providers
Affects Version/s: PUP 3.6.2
Fix Version/s: PUP 3.7.5

Type: Bug Priority: Normal
Reporter: John Hodrien Assignee: Unassigned
Resolution: Fixed Votes: 3
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


Issue Links:
relates to PUP-4744 Yumrepo doesn't recognize whitespace ... Closed
Story Points: 3
Sprint: RE 2015-02-11, RE 2015-02-25, RE 2015-03-11
QA Contact: Eric Thompson


With yum.conf containing reposdir=/etc/yum.repos.d/custom all was well with 3.4.3 and puppet managed the repo files correctly.

Since the 3.5 changes to yumrepo, it no longer uses the custom repodir, so writes the repo files to the wrong directory (/etc/yum.repos.d). But then yum isn't reading them from this directory, so none of them are picked up by yum.

Comment by Steve Traylen [ 2014/09/23 ]

Looking at 3.7.1 the logic is

 def self.reposdir(conf='/etc/yum.conf', dirs=['/etc/yum.repos.d', '/etc/yum/repos.d'])
    reposdir = find_conf_value('reposdir', conf)
    dirs << reposdir if reposdir

which says use the following if the directories exist

  • /etc/yum.repos.d
  • /etc/yum/repos.d
  • <reposdir> value

It ignores them if the directory does not exist. So if your delete /etc/yum.repos.d
the old behaviour is restored of writing to reposdir , this is a workaroud.

I agree though this is undesirable. A 'reposdir' setting in the yum.conf
should always win since that is what is actually used by yum.

p.s very happy to see yumrepo type is much improved overall.

Comment by David LeVene [ 2014/09/29 ]

I'm also running into this issue as we use another yum repo directory for our stuff.

Based on the comment above, I don't believe this is exactly correct - while the code pasted is current the behavior that i've seen on puppet 3.7.1 client & server + ruby 2.1.2 is if neither directory exists it doesn't honor the value in /etc/yum.conf it just puts the repos in /etc/yum.conf.

This is actually stopping us from upgrading to the latest version of puppet as we don't want to loose the setup we have. We were looking at purging the other directory but it seems that this is still a feature request as well (https://projects.puppetlabs.com/issues/1023)

Would another approach to this to include an option to tell where to create the yumrepo via an attribute? I see there is already a target attrib, but I'm not sure if this accepts a path as well - unfortunately my knowledge of how providers are structured & setup is minimal.

newparam(:target) do
desc "The filename to write the yum repository to."

defaultto :absent

Comment by Steve Traylen [ 2014/09/30 ]

Based on the comment above, I don't believe this is exactly correct

Yes you are correct and I was wrong . I see no way to populate a custom location directory.

As you say if I

  • delete default directory
  • Set a reposdir in yum.conf to a custom location
  • Create that custom directory

the yumrepos are still created in /etc/yum.conf.

Comment by Daniel Sung [ 2014/10/22 ]

So this bug has also been a blocker for me too, so I thought I'd have a quick look to see what was wrong with the provider. I think I can see three issues:

  • Firstly, the find_conf_value method initializes the PhysicalFile but it is never read/parsed, therefore find_conf_value always returns nil at the moment, no matter whether the reposdir setting in yum.conf is present or not.
  • Secondly, the provider makes the assumption that the custom reposdir is added to an array along with the default directory, where in reality, it replaces the default directory and any repofiles in the default directory are ignored by yum.
  • Lastly, it is also assuming that the custom reposdir can be ignored if the directory doesn't exist and fall back onto the default, wherein reality yum doesn't do this.

I have made some changes to the provider that seems to work for me, but it looks like the unit tests make these same (incorrect) assumptions.

Comment by Daniel Sung [ 2014/10/22 ]

I have made a pull request with a fix:


Comment by Scott Garman [ 2015/01/20 ]

Changing status back to in progress since there are still remaining issues in the PR to be fixed.

Comment by Scott Garman [ 2015/02/06 ]

Note: this has been merged into master, but a second PR has been created to get this into stable as well since it's a regression bug.

Edit: merge for stable branch is complete as of 2015-02-09. Entering CI.

Comment by Eric Thompson [ 2015/03/02 ]

verified on rhel7 at SHA: 2458a71

[root@fe3bsczu8tto8hg puppet]# cat /etc/yum.conf
[root@fe3bsczu8tto8hg puppet]# puppet resource yumrepo
yumrepo { 'rhel7-extras':
  ensure   => 'present',
  baseurl  => 'http://osmirror.delivery.puppetlabs.net/rhel7latestserver-x86_64/RPMS.extras/',
  descr    => 'Red Hat Enterprise Linux 7 - $basearch - Extras',
  enabled  => '0',
  gpgcheck => '1',
  gpgkey   => 'file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release',
yumrepo { 'rhel7-optional':
  ensure   => 'present',
[root@fe3bsczu8tto8hg puppet]# cat /etc/yum.conf
[root@fe3bsczu8tto8hg puppet]# puppet resource yumrepo
yumrepo { 'yep':
  ensure  => 'present',
  baseurl => 'http://fake.co',

Generated at Tue Jul 14 02:55:51 PDT 2020 using Jira 8.5.2#805002-sha1:a66f9354b9e12ac788984e5d84669c903a370049.