On Jun 24, 2011, at 11:48 AM, James A. Peltier wrote:
> Hi All,
>
> I'm new to puppet and I'm having some difficulty enabling and disabling yum
> repositories on an as needed basis and I was wondering if you all might be
> able to provide me with some assistance. I've been able to get puppet to
> configure a yum repository, I'm going to use EPEL as an example here but I'd
> like it for all, by creating a class called epel.pp containing
>
> class epel {
> yumrepo { "epel": descr => "Extra Packages for Enterprise Linux \$releasever
> - \$basearch", baseurl =>
> "http://mirror.its.sfu.ca/mirror/CentOS-Third-Party/epel/\$releasever/\$basearch",
> gpgcheck => 1, gpgkey =>
> "http://mirror.its.sfu.ca/mirror/CentOS-Third-Party/epel/RPM-GPG-KEY-EPEL",
> enabled=0 }
> }
>
> and it does create and populate the /etc/yum.repos.d/epel.repo file with this
> information. Now I want to be able to install ganglia-gmond automatically
> from this repository but I can't figure out how to enable and disable the
> repo afterwards? Can anyone please provide an example of how something like
> this may be accomplished?
----
I've been at this for less than a week and primarily concentrating on ubuntu,
not RHEL/CentOS so take this with a grain of salt
You have to be careful when installing packages from another repo but
generally, you just keep the EPEL repo disabled and instead of using the
built-in package command, you would want to 'exec' something like...
exec('/usr/bin/yum --enablerepo=epel install -y ganglia-gmond') and I would
also note that you have to ensure that the rpm-gpg key is installed for the
epel repo BEFORE that command is executed - I believe you already provided the
gpg-key URL to us.
something like this should work (adapt for rpm/yum and note that rpm stores
keys in /etc/pki/rpm-gpg)...
class apt {
package { "apt":
ensure => installed,
}
file{"/etc/apt/sources.list":
ensure => present,
owner => root,
group => root,
mode => 0444,
content => template("apt/sources.list.erb"),
require => Package["apt"],
}
exec{"/usr/bin/apt-get update":
refreshonly => true,
subscribe => File["/etc/apt/sources.list"],
require => File["/etc/apt/sources.list"],
}
# MongoDB Key
apt::key { "7F0CEB10":
keyid => "7F0CEB10",
ensure => present,
}
}
define apt::key($keyid, $ensure, $keyserver = "keyserver.ubuntu.com") {
case $ensure {
present: {
exec { "Import $keyid to apt keystore":
path => "/bin:/usr/bin",
environment => "HOME=/root",
command => "gpg --keyserver $keyserver --recv-keys $keyid && gpg
--export --armor $keyid | apt-key add -",
user => "root",
group => "root",
unless => "apt-key list | grep $keyid",
logoutput => on_failure,
}
}
absent: {
exec { "Remove $keyid from apt keystore":
path => "/bin:/usr/bin",
environment => "HOME=/root",
command => "apt-key del $keyid",
user => "root",
group => "root",
onlyif => "apt-key list | grep $keyid",
}
}
default: {
fail "Invalid 'ensure' value '$ensure' for apt::key"
}
}
}
--
You received this message because you are subscribed to the Google Groups
"Puppet Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/puppet-users?hl=en.