Puppet Class: yum
- Inherits:
- yum::params
- Defined in:
- manifests/init.pp
Overview
Class: yum
This class manages yum repositories for RedHat based distros: RHEL, Centos, Scientific Linux
Copyright 2008, admin(at)immerda.ch Copyright 2008, Puzzle ITC GmbH Marcel Harry haerry+puppet(at)puzzle.ch Simon Josi josi+puppet(at)puzzle.ch
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 3 as published by the Free Software Foundation.
Apapted for Example42 by Alessandro Franceschi
Parameters
- install_all_keys
-
If to provide all the module’s known rpm gpgp keys. Default true, set to false to keep backwards compatibility
- update
-
If you want yum automatic updates. Possibile values: cron - Updates in a cronjob updatesd - Updates via updatesd (Only on Centos/RedHat/SL 5) false/no - Automatic updates disabled (Default)
- update_disable
-
Set to true if you have enabled updates and now wish to disable Defaults to false. Logic pertaining to this parameter is only applied when the update method parameter (immediately above) is set.
- defaultrepo
-
If you want to enable default repositories for supported OS Default: true Note: This variable is ignored if you provide a custom source_repo_dir
- extrarepo
-
If you want to enable some (supported) extra repositories Can be an array. Default: ‘epel’ (Epel is used by many modules) Note: This variable is ignored if you provide a custom source_repo_dir
- plugins_config_dir
-
The path of the plugins configuration directory
- repo_dir
-
The path of the yum.repos.d directory
- source_repo_dir
-
The source path to use to populate the yum.repos.d directory
- clean_repos
-
Boolean. Defines if you want to cleanup the yum.repos.d dir and be sure that it contains only files managed by Puppet Default: false
- my_class
-
Name of a custom class to autoload to manage module’s customizations If defined, yum class will automatically “include $my_class” Can be defined also by the (top scope) variable $yum_myclass
- source
-
Sets the content of source parameter for main configuration file If defined, yum main config file will have the param: source => $source Can be defined also by the (top scope) variable $yum_source
- source_dir
-
If defined, the whole yum configuration directory content is retrieved recursively from the specified source (source => $source_dir , recurse => true) Can be defined also by the (top scope) variable $yum_source_dir
- source_dir_purge
-
If set to true (default false) the existing configuration directory is mirrored with the content retrieved from source_dir (source => $source_dir , recurse => true , purge => true) Can be defined also by the (top scope) variable $yum_source_dir_purge
- template
-
Sets the path to the template to use as content for main configuration file If defined, yum main config file has: content => content(“$template”) Note source and template parameters are mutually exclusive: don’t use both Can be defined also by the (top scope) variable $yum_template
- options
-
An hash of custom options to be used in templates for arbitrary settings. Can be defined also by the (top scope) variable $yum_options
- absent
-
Set to ‘true’ to remove package(s) installed by module Can be defined also by the (top scope) variable $yum_absent
- disable
-
Set to ‘true’ to disable service(s) managed by module Can be defined also by the (top scope) variable $yum_disable
- disableboot
-
Set to ‘true’ to disable service(s) at boot, without checks if it’s running Use this when the service is managed by a tool like a cluster software Can be defined also by the (top scope) variable $yum_disableboot
- puppi
-
Set to ‘true’ to enable creation of module data files that are used by puppi Can be defined also by the (top scope) variables $yum_puppi and $puppi
- puppi_helper
-
Specify the helper to use for puppi commands. The default for this module is specified in params.pp and is generally a good choice. You can customize the output of puppi commands for this module using another puppi helper. Use the define puppi::helper to create a new custom helper Can be defined also by the (top scope) variables $yum_puppi_helper and $puppi_helper
- debug
-
Set to ‘true’ to enable modules debugging Can be defined also by the (top scope) variables $yum_debug and $debug
- audit_only
-
Set to ‘true’ if you don’t intend to override existing configuration files and want to audit the difference between existing files and the ones managed by Puppet. Can be defined also by the (top scope) variables $yum_audit_only and $audit_only
- config_dir
-
Main configuration directory. Used by puppi
- config_file
-
Main configuration file path
- config_file_mode
-
Main configuration file path mode
- config_file_owner
-
Main configuration file path owner
- config_file_group
-
Main configuration file path group
- cron_params
-
Optional extra arguments for $update = cron ONLY
- cron_mailto
-
Optional mail addres to send update reports for $update = cron ONLY
- cron_dotw
-
Days of the week to perform yum updates by cron 0123456 (default)
- log_file
-
Log file(s). Used by puppi
- persist_dir
-
Persistent information store directory path
- cache_dir
-
cache and db files directory path
- bool_priorities_plugin
-
Boolean. If true, the priorities plugin will be installed automatically Default: true
166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 |
# File 'manifests/init.pp', line 166
class yum (
$install_all_keys = params_lookup( 'install_all_keys' ),
$update = params_lookup( 'update' ),
$update_disable = params_lookup( 'update_disable' ),
$defaultrepo = params_lookup( 'defaultrepo' ),
$extrarepo = params_lookup( 'extrarepo' ),
$plugins_config_dir = params_lookup( 'plugins_config_dir' ),
$repo_dir = params_lookup( 'repo_dir' ),
$source_repo_dir = params_lookup( 'source_repo_dir' ),
$clean_repos = params_lookup( 'clean_repos' ),
$my_class = params_lookup( 'my_class' ),
$source = params_lookup( 'source' ),
$source_dir = params_lookup( 'source_dir' ),
$source_dir_purge = params_lookup( 'source_dir_purge' ),
$template = params_lookup( 'template' ),
$options = params_lookup( 'options' ),
$absent = params_lookup( 'absent' ),
$disable = params_lookup( 'disable' ),
$disableboot = params_lookup( 'disableboot' ),
$puppi = params_lookup( 'puppi' , 'global' ),
$puppi_helper = params_lookup( 'puppi_helper' , 'global' ),
$debug = params_lookup( 'debug' , 'global' ),
$audit_only = params_lookup( 'audit_only' , 'global' ),
$config_dir = params_lookup( 'config_dir' ),
$config_file = params_lookup( 'config_file' ),
$config_file_mode = params_lookup( 'config_file_mode' ),
$config_file_owner = params_lookup( 'config_file_owner' ),
$config_file_group = params_lookup( 'config_file_group' ),
$update_template = params_lookup( 'update_template' ),
$cron_param = params_lookup( 'cron_param' ),
$cron_mailto = params_lookup( 'cron_mailto' ),
$cron_dotw = params_lookup( 'cron_dotw' ),
$cron_clean_dotw = params_lookup( 'cron_clean_dotw' ),
$cron_update_cmd = params_lookup( 'cron_update_cmd' ),
$cron_update_messages = params_lookup( 'cron_update_messages' ),
$cron_apply_updates = params_lookup( 'cron_apply_updates' ),
$cron_random_sleep = params_lookup( 'cron_random_sleep' ),
$cron_emit_via = params_lookup( 'cron_emit_via' ),
$cron_email_host = params_lookup( 'cron_email_host' ),
$log_file = params_lookup( 'log_file' ),
$manage_persist_dir = params_lookup( 'manage_persist_dir' ),
$persist_dir = params_lookup( 'persist_dir'),
$manage_cache_dir = params_lookup( 'manage_cache_dir' ),
$cache_dir = params_lookup( 'cache_dir'),
$priorities_plugin = params_lookup( 'priorities_plugin' )
) inherits yum::params {
$bool_install_all_keys=any2bool($install_all_keys)
$bool_defaultrepo=any2bool($defaultrepo)
$bool_clean_repos=any2bool($clean_repos)
$bool_source_dir_purge=any2bool($source_dir_purge)
$bool_absent=any2bool($absent)
$bool_disable=any2bool($disable)
$bool_disableboot=any2bool($disableboot)
$bool_puppi=any2bool($puppi)
$bool_debug=any2bool($debug)
$bool_audit_only=any2bool($audit_only)
$bool_priorities_plugin=any2bool($priorities_plugin)
$bool_update_disable=any2bool($update_disable)
$bool_manage_persist_dir=any2bool($manage_persist_dir)
$bool_manage_cache_dir=any2bool($manage_cache_dir)
$osver = $::operatingsystem ? {
'XenServer' => [ '5' ],
default => split($::operatingsystemrelease, '[.]')
}
$manage_service_enable = $yum::bool_disableboot ? {
true => false,
default => $yum::bool_disable ? {
true => false,
default => $yum::bool_absent ? {
true => false,
false => true,
},
},
}
$manage_service_ensure = $yum::bool_disable ? {
true => 'stopped',
default => $yum::bool_absent ? {
true => 'stopped',
default => 'running',
},
}
$manage_file = $yum::bool_absent ? {
true => 'absent',
default => 'present',
}
$manage_audit = $yum::bool_audit_only ? {
true => 'all',
false => undef,
}
$manage_file_replace = $yum::bool_audit_only ? {
true => false,
false => true,
}
$manage_file_source = $yum::source ? {
'' => undef,
default => $yum::source,
}
$manage_file_content = $yum::template ? {
'' => undef,
default => template($yum::template),
}
$manage_updates = $yum::update ? {
'cron' => true,
'updatesd' => true,
default => false,
}
# XXX param_lookup returns '' instead of undef
$real_source_repo_dir = $yum::source_repo_dir ? {
'' => undef,
default => $yum::source_repo_dir,
}
file { 'yum.repo_dir':
ensure => directory,
path => $yum::repo_dir,
source => $real_source_repo_dir,
recurse => true,
purge => $yum::bool_clean_repos,
replace => $yum::manage_file_replace,
audit => $yum::manage_audit,
}
if $real_source_repo_dir == undef {
include yum::defaults
}
# Yum Configuration file
file { 'yum.conf':
ensure => $yum::manage_file,
path => $yum::config_file,
mode => $yum::config_file_mode,
owner => $yum::config_file_owner,
group => $yum::config_file_group,
source => $yum::manage_file_source,
content => $yum::manage_file_content,
replace => $yum::manage_file_replace,
audit => $yum::manage_audit,
}
# The whole yum configuration directory can be recursively overriden
if $yum::source_dir and $yum::source_dir != '' {
file { 'yum.dir':
ensure => directory,
path => $yum::config_dir,
source => $yum::source_dir,
recurse => true,
purge => $yum::source_dir_purge,
replace => $yum::manage_file_replace,
audit => $yum::manage_audit,
}
}
# set the premissions for the cache and persist dirs recursively
if $bool_manage_persist_dir {
file { 'yum.persist.dir':
ensure => directory,
path => $yum::persist_dir,
mode => $yum::config_file_mode,
owner => $yum::config_file_owner,
group => $yum::config_file_group,
recurse => true,
}
}
if $bool_manage_cache_dir {
file { 'yum.cache.dir':
ensure => directory,
path => $yum::cache_dir,
mode => $yum::config_file_mode,
owner => $yum::config_file_owner,
group => $yum::config_file_group,
recurse => true,
}
}
### Manage Automatic Updates
if $yum::manage_updates {
include "::yum::${update}"
}
### Include custom class if $my_class is set
if $yum::my_class and $yum::my_class != '' {
include $yum::my_class
}
### Provide puppi data, if enabled ( puppi => true )
if $yum::bool_puppi == true {
$classvars=get_class_args()
puppi::ze { 'yum':
ensure => $yum::manage_file,
variables => $classvars,
helper => $yum::puppi_helper,
}
}
### Debugging, if enabled ( debug => true )
if $yum::bool_debug == true {
file { 'debug_yum':
ensure => $yum::manage_file,
path => "${settings::vardir}/debug-yum",
mode => '0640',
owner => 'root',
group => 'root',
content => inline_template('<%= scope.to_hash.reject { |k,v| k.to_s =~ /(uptime.*|path|timestamp|free|.*password.*|.*psk.*|.*key)/ }.to_yaml %>'),
}
}
}
|