The following terms defined live in category Resources & Types.
By grouping these terms together, the authors hope to shed some light on when something is a
type, when it becomes an instantiated type, and when it is a
resource. Also, we bring the term
system resource to the table, hopefully making a sufficiently clear distinction between two different perspectives.
Type or Resource?
The terms type and resource are very closely aligned. It's very easy to mix them up and so that's what happens throughout the Puppet community. I'm not saying I know better, but there is subtle syntax differences:
When addressing a type, you do so in all lowercase characters (file { blabla).
When addressing a resource (a previously instantiated type), you do so capitalized (File["blabla).
A system resource is a real resource from the perspective of the node or Operating System instance. This means a system resource does not have to physically exist, and does not have to relate to anything physical. Mind that when we manage users on a box that runs directly on physical hardware, we're still not managing anything truly physical, are we?
When we want to start managing the web service on a node, we'd say we need to manage the
system resource(s) controlling the web service (often
httpd within classic style
initscripts), resulting in a
resource Service["httpd"] (of instantiated
type service) with
parameter ensure set to
running and
parameter enable set to
true.
A
defined type can be instantiated multiple times, similar to a
native type, as long as the
resource ends up with a unique name, and the resources instantiated by the
defined type conform to the set of rules applicable to the types used. For example, you cannot instantiate defined type
foo twice by using
foo { "bar": enable => true } twice. This violates the
resource uniqueness constraint, and the second attempt to instantiate the
defined type foo will fail.
You can, however, instantiate defined type foo twice by using different names:
foo { [
"bar",
"baz"
]:
}
Again, the types instantiated by the defined type foo will still need to obey the rules for these types. The following snippet will not work:
define foo() {
file { "/tmp/file":
content => "$name"
}
}
foo { [
"bar",
"baz"
]:
}
This will not work, because
resource File["/tmp/file"] is now defined twice.
What would work though, and this is also the power of defined types;
define foo() {
file { "/tmp/$name":
content => "$name"
}
}
foo { [
"bar",
"baz"
]:
}
Now, both resources File["/tmp/bar"] and File["/tmp/baz"] can be applied to the system (and become true system resources).
plugin type