How to force Puppet to use a specific yum repo?

1,194 views
Skip to first unread message

staceyt...@gmail.com

unread,
Jan 6, 2015, 9:59:16 AM1/6/15
to puppet...@googlegroups.com
Hi,

I am using open source Puppet 3.7.3. There are multiple yum repos on the puppet agent machines. So when I use Puppet to push a package, can I force Puppet to use a specific yum repo?

For example, here is my module for pushing Firefox:

class firefox::checkff inherits firefox {
  if ( ($operatingsystemrelease >= 6.5) and ($hardwareisa == 'x86_64') ) {
 
    file { "/etc/yum.repos.d/firefox.31.2.x86_64.repo":
      ensure => present,
      source => "/templates/Linux/yum.repos.d/firefox.31.2.x86_64.repo",
      mode => '0644',
      owner => 'root',
    }

    package { "gtk2":
      ensure => '2.24.23-6.el6',
    }

    package { "firefox":
      ensure => '31.2.0-3.el6_6',
      subscribe => [ Package['gtk2'] ],
    }
  }
}

You can see that I make sure my firefox.31.2.x86_64.repo is copied to the local machine's /etc/yum.repos.d, but I found out that my puppet agent will still try to get the firefox package from my Satellite server instead of installing from the local firefox repo.

Is there any way to force Puppet to use a specific yum repo?

Thanks,
Stacey

Felix Frank

unread,
Jan 6, 2015, 6:10:18 PM1/6/15
to puppet...@googlegroups.com
Hi,

I have next to no experience with yum, but generally you should try and

1. use the yumrepo type:
https://docs.puppetlabs.com/references/latest/type.html#yumrepo
2. make sure the package *require* the repository
3. perhaps pass the enablerepo option via the install_options parameter:
https://docs.puppetlabs.com/references/latest/type.html#package-attribute-install_options

HTH,
Felix

jcbollinger

unread,
Jan 7, 2015, 9:09:18 AM1/7/15
to puppet...@googlegroups.com
You could set appropriate yum flags in the package's 'install_options' parameter, but don't.  It would be better to alter your repository configuration so that 'yum' chooses the desired repo by default.  This will avoid pain later.  There are several ways to do that, but if you want to completely preclude the possibility that Firefox is installed from the satellite server repo then configure 'firefox' among that repo's excluded packages.  Puppet can assist you with that, via the Yumrepo resource type.


John

kaustubh chaudhari

unread,
Jan 7, 2015, 9:52:56 AM1/7/15
to puppet...@googlegroups.com
Hey,

You cannot force puppet to use specific repo, puppet uses yum and then yum decides which repo to use for what. You can alter your yum.repos file to add
==
exclude= < packagename >
==

this will exclude the package from the specific repos, eventually it will pick up the package from the repos that you want.

Also make sure you run # yum clean all, to clear all metadata.

-HTH
Kaustubh
Reply all
Reply to author
Forward
0 new messages