August 2015
Intermediate to advanced
144 pages
2h 58m
English
Defined types are great for reducing the complexity and improving the readability of your code. However, they can lead to some interesting problems that may be difficult to diagnose.
In the following code, we create a defined type that creates a host entry:
define myhost ($short,$ip) {
host {"$short":
ip => $ip,
host_aliases => [
"$title.example.com",
"$title.example.net",
"$short"
],
}
}In this define, the namevar for the host resource is an argument of the define, the $short variable.
In Puppet, there are two important attributes of any resource—the namevar and the title. The confusion lies in the fact that, sometimes, both of these attributes have the same value. Both values must be unique, but they are used differently. The title ...
Read now
Unlock full access