C.1. Example Defined Type
A defined type is a custom type you can define yourself. This can be a shortcut to a collection of resources given a set of parameters, or just a single resource, as shown in the following examples.
You can use this defined type to manage the files in
/etc/yum/repos.d/, and thus the repositories available to the YUM package manager, by calling (for example):
yum::repository { "custom":
enable => true
}
This will create a File["/etc/yum/repos.d/custom.repo"] and grab if from a location on the puppetmaster's fileserver where it has enabled=1 in the repository configuration file. Should $enable have been set to false in the Yum::Repository["custom"] resource, then the file would have been grabbed from the location on the puppetmaster's fileserver where the contents would have enabled=0.
This is an example
define yum::plugin($enable = false) {
file { "/etc/yum/pluginconf.d/$name.conf":
ensure => $enable ? {
true => file,
default => absent
},
owner => "root",
group => "root",
mode => 644,
source => "puppet:///yum/plugins/$name.conf"
}
package { "yum-$name":
ensure => $enable ? {
true => installed,
default => absent
}
}
case $name {
"versionlock": {
file { "/etc/yum/pluginconf.d/versionlock.list":
source => "puppet:///yum/plugins/versionlock.list"
}
}
}
}