yum disable/enable repo with wildcards

1,376 views
Skip to first unread message

Vince Skahan

unread,
Jul 2, 2015, 3:52:26 PM7/2/15
to puppet...@googlegroups.com

We've set up local mirrors of a number of upstream repos, and want to point our puppet-managed boxes at the local mirrors only.

Assuming we named our mirror repos local-mirror-whatever, if I was using yum on the commandline, I could do it on the fly by disabling all repos and then enabling the repo(s) that I wanted visible for that yum transaction ala:
    yum --disablerepo=* --enablerepo=local-mirror* install foo

Is there a clean way to do this in puppet ?

Alternately, I guess I could just remove all the files (other than ours) in /etc/yum.repos.d but that seems a little kludgey to me and I'd need to make sure that subsequent yum updates didn't put them back on me.

Any ideas ?


Christopher Peterson

unread,
Jul 2, 2015, 5:43:04 PM7/2/15
to puppet...@googlegroups.com
There may be a more Puppety way of doing this, but your disable/enable
method can be done with Puppet too. You can pass those options in the
install_options for your Package.

https://docs.puppetlabs.com/references/latest/type.html#package-attribute-install_options

Christopher Peterson

On 07/02/2015 11:52 AM, Vince Skahan wrote:
>
> We've set up local mirrors of a number of upstream repos, and want to
> point our puppet-managed boxes at the local mirrors only.
>
> Assuming we named our mirror reposlocal-mirror-whatever, if I was using
> yum on the commandline, I could do it on the fly by disabling all repos
> and then enabling the repo(s) that I wanted visible for that yum
> transaction ala:
> yum --disablerepo=* --enablerepo=local-mirror* install foo
>
> Is there a clean way to do this in puppet ?
>
> Alternately, I guess I could just remove all the files (other than ours)
> in /etc/yum.repos.d but that seems a little kludgey to me and I'd need
> to make sure that subsequent yum updates didn't put them back on me.
>
> Any ideas ?
>
>
> --
> You received this message because you are subscribed to the Google
> Groups "Puppet Users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to puppet-users...@googlegroups.com
> <mailto:puppet-users...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/puppet-users/19ddcb3e-8b2a-4540-9531-4843ae3fcf91%40googlegroups.com
> <https://groups.google.com/d/msgid/puppet-users/19ddcb3e-8b2a-4540-9531-4843ae3fcf91%40googlegroups.com?utm_medium=email&utm_source=footer>.
> For more options, visit https://groups.google.com/d/optout.

jcbollinger

unread,
Jul 6, 2015, 2:44:17 PM7/6/15
to puppet...@googlegroups.com


Puppet provides a Yumrepo resource type for managing Yum repository definitions.  It has an 'enabled' property, which you can set false to disable repos you want to keep but not use.  This has the advantage that you no longer need to disable these repos from the command line, either, but the disadvantage that it affects only the repos you in fact manage.

If you are concerned that unmanaged repos may be be added to your systems, and you are running at least Puppet 3.5, then you should be able to use the Resources metaresource to purge unmanaged repos.


John

Vince Skahan

unread,
Jul 6, 2015, 5:14:30 PM7/6/15
to puppet...@googlegroups.com
On Monday, July 6, 2015 at 7:44:17 AM UTC-7, jcbollinger wrote:
Puppet provides a Yumrepo resource type for managing Yum repository definitions.  It has an 'enabled' property, which you can set false to disable repos you want to keep but not use.  This has the advantage that you no longer need to disable these repos from the command line, either, but the disadvantage that it affects only the repos you in fact manage.


I worked around it for the moment by using install_options ala:

  package { 'xyz':
    ensure => installed,
    install_options => [ { "--disablerepo" => "*" }, { "--enablerepo"  => "localmirror-*" }, ],
  }

But yes I guess just disabling the upstream repos is the right way to go, as their names are well known.
 

If you are concerned that unmanaged repos may be be added to your systems, and you are running at least Puppet 3.5, then you should be able to use the Resources metaresource to purge unmanaged repos.


I'm struggling with translating that last statement into English I can understand.....have an example I could try ?

jcbollinger

unread,
Jul 7, 2015, 1:14:59 PM7/7/15
to puppet...@googlegroups.com


On Monday, July 6, 2015 at 12:14:30 PM UTC-5, Vince Skahan wrote:
On Monday, July 6, 2015 at 7:44:17 AM UTC-7, jcbollinger wrote:

[...]
 

If you are concerned that unmanaged repos may be be added to your systems, and you are running at least Puppet 3.5, then you should be able to use the Resources metaresource to purge unmanaged repos.


I'm struggling with translating that last statement into English I can understand.....have an example I could try ?



Yes:

resources { 'purge unmanaged Yum repos':
  name
=> 'yumrepo',
  purge
=> true
}

Warning: apply that only to systems on which all repo definitions you want to retain are managed by Yumrepo resources.  Any others (that Puppet finds) will be completely removed.

See the docs for the Resources (meta-) resource type for a bit more information.


John

Reply all
Reply to author
Forward
0 new messages