Introduction
Manifests are files containing Puppet code. They are standard text files saved with the .pp extension. Most manifests should be arranged into modules.
Resources
The core of the Puppet language is declaring resources. A resource declaration looks like this:
# A resource declaration:
cisco_interface { "Ethernet1/2" :
description => 'default',
shutdown => 'default',
access_vlan => 'default',
}
When a resource depends on another resource, you should explicitly state the relationship to make sure they occur in the proper order.
Classes
A class is a set of common configurations — resources, variables and more advanced attributes. Anytime we assign this class to a machine, it will apply those all configurations within the class.
Modules
A Puppet module is just a collection of files and directories that can contain Puppet manifests, as well as other objects such as files and templates, all packaged and organized in a way that Puppet can understand and use. When you download a module from PuppetForge, you are downloading a top-level directory with several subdirectories that contain the components needed to specify the desired state. When you want to use that module to manage your nodes, you classify each node by assigning to it a class within the module.
The hierarchy is as follows:
- Resources can be contained within classes.
- Classes can live in a manifest.
- Manifests can live in a module.
Sample Manifest
Three types are needed to add OSPF support on an interface: cisco_ospf, cisco_ospf_vrf, and cisco_interface_ospf.
First, to configure cisco_ospf to enable ospf on the device, add the following type in the manifest:
cisco_ospf {"Sample":
ensure => present,
}
Then put the ospf router under a VRF, and add the corresponding OSPF configuration.
If the configuration is global, use 'default' as the VRF name:
cisco_ospf_vrf {"Sample default":
ensure => 'present',
default_metric => '5',
auto_cost => '46000',
}
Finally, apply the ospf configuration to the interface:
cisco_interface_ospf {"Ethernet1/2 Sample":
ensure => present,
area => 200,
cost => "200",
}