In Chapter 3, Managing your Puppet code with Git, we introduced the node
keyword and explained that you can use node definitions to control which resources are applied to a given node. It's time to look at node definitions in a little more detail, and explore more sophisticated ways to organize your manifests, including roles and profiles.
As you know, when you apply a manifest to a node, by default Puppet applies all the resources declared in the manifest. When we have more than one node, we probably want different resources applied to different nodes, so how do we do that?
The node
keyword introduces a node definition, and all the resources contained in the node definition will only be applied on nodes whose hostname matches the node name (node_app1.pp
):
node 'app1' { file { '/tmp/only_on_app1': content => "I'm only needed on the node named 'app1'!", } }
Node definitions should live in a file in the manifests
directory. A node definition...