Commit 571be85b authored by Emmanuel Medernach's avatar Emmanuel Medernach
Browse files

Managing Yum repositories with profiles

parent e4bc485f
## Yum repository management
### Example
File hiera.yaml:
```
:hierarchy:
...
- yum # yum::description
...
```
Restart puppetserver if needed
File yum.yaml:
```
yum::description:
linuxtech-release:
baseurl:
http://linuxsoft.cern.ch/linuxtech/el6/release/
http://pkgrepo.linuxtech.net/el6/release/
mirrorlist: http://pkgrepo.linuxtech.net/el6/release/mirrorlist.txt
gpgkey: http://pkgrepo.linuxtech.net/el6/release/RPM-GPG-KEY-LinuxTECH.NET
enabled: 1
gpgcheck: 1
metadata_expire: 7d
skip_if_unavailable: 0
linuxtech-testing:
baseurl:
http://linuxsoft.cern.ch/linuxtech/el6/testing/
http://pkgrepo.linuxtech.net/el6/testing/
mirrorlist: http://pkgrepo.linuxtech.net/el6/testing/mirrorlist.txt
gpgkey: http://pkgrepo.linuxtech.net/el6/release/RPM-GPG-KEY-LinuxTECH.NET
enabled: 0
gpgcheck: 1
metadata_expire: 7d
skip_if_unavailable: 0
yum::repositories:
base:
- linuxtech-release
- linuxtech-testing
```
File <node>.yaml:
```
yum::distroversionpackage: centos-release
yum::profile: base
yum::packages:
- centos-release
- epel-release
- boost-devel
```
module Puppet::Parser::Functions
newfunction(:array2hash, :type => :rvalue) do |args|
myarray = args[0]
myhash = args[1]
result = Hash.new
myarray.each { |key|
result[key] = myhash[key]
}
return ( result )
end
end
class yum::config {
case $facts['os']['name'] {
'CentOS': {
package { 'epel-release':
ensure => installed,
}
}
default: { warning("Unknown OS : ${$facts['os']['name']}") }
file { "/etc/yum.conf":
owner => 'root',
group => 'root',
mode => '0644',
content => template('yum/yum.conf.erb'),
}
$listofrepos = array2hash($yum::repositories[$yum::profile], $yum::description)
create_resources(yumrepo, $listofrepos)
}
class yum {
class yum(
$distroversionpackage, # distroverpkg variable from yum.conf
$reposdir = '/etc/yum.repos.d', # Repository directory
$description, # List of all available repositories
$repositories, # List of repositories to be installed
$packages, # List of packages to install
$profile, # Profile type (set of repositories to install)
) {
package { $packages:
ensure => 'installed',
}
file { $reposdir:
ensure => directory,
owner => "root",
mode => "0755",
}
include yum::config
}
[main]
cachedir=/var/cache/yum/$basearch/$releasever
keepcache=0
debuglevel=2
logfile=/var/log/yum.log
exactarch=1
obsoletes=1
gpgcheck=1
plugins=1
installonly_limit=5
distroverpkg=<%= scope['yum::distroversionpackage'] %>
reposdir=<%= scope['yum::reposdir'] %>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment